Creating empty-tag-elements with JAXB?

Hi,
is there any possibility to force JAXB to create empty-tag-elements? For example
<exampletag attribute="value" />
instead of
<exampletag attribute="value">
</exampletag>.
I really need to close my tags in the described way but have found no possibility to do so.
Thanks for your help
Daniel

Maybe this will help. I take advantage of the following behavior of the JAXB Marshaller to give me the form of output I require.
When a class (element) has "null" content, the output is of the form <tagger id="Unique"/>. When it has "empty" content, the output is of the form <tagger id="Unique"></tagger>.
Example code snippets:
For "null" content:
@XmlRootElement(name = "tagger")
public class TagClose
  public void setId(String id) { this.id = id; }
  public String getId() { return this.id; }
  @XmlValue
  String content = null;
  @XmlAttribute(name="id")
  String id = null;
}For "empty" content:
@XmlRootElement(name = "tagger")
public class TagClose
  public void setId(String id) { this.id = id; }
  public String getId() { return this.id; }
  @XmlValue
  String content = "";
  @XmlAttribute(name="id")
  String id = null;
}

Similar Messages

  • Can't create dynamic html elements with jsp????? important

    Hi All,
    I am having problem creating dynamic html elements with jsp tags, i have tried to use EL and java scriplet, both of them don't work.
    i am trying to create dynamic menu in my "rightMenu.jspf", based on, if user has logged in or not.
    some like this!
    <jsp:if test ="${validUser == null}">
    some simple text menu here
    </jsp:if>
    but it is not working. it simply loading all and images with in statement, regardless of whether user has logged in or not. i think some how if statement is not working properly.
    "validUser" is a session bean, which is not creating at this point, it will created when user will log in successfully. and also this session bean does not exist at the page, where i am trying to check that .
    Is there any way to create dynamic values in jsp. It is really important, is there any body who help me in this matter. i would be really grateful.
    zaman

    hi jaspre,
    thanks for replying me. you know what, is it not something wrong with web.xml file. i remember once, i deleted some from there, a property with "*.jsp". i can't remember what exactly was it though.
    all if statements works on files ending with extension ".jsp" but don't work only on with extension ".jspf". there must be to do with this.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
    <servlet-name>ValidateServlet</servlet-name>
    <servlet-class>ValidateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ValidateServlet</servlet-name>
    <url-pattern>/ValidateServlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>pollAndCometEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    main.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if any one can figure it out. i would be grateful.
    zaman

  • Is it possible to create a tagged pdf with apple pages?

    Not sure if possible and any tutorials would be appreciated.

    > Is it possible to create a tagged PDF with Apple Pages?
    Short answer: No, Apple chose at the introduction of Mac OS X to support only Adobe PDF 1.3 and those parts of Adobe PDF 1.4 that include device-independent transparency, but not those parts of Adobe PDF 1.4 that include Adobe XMP for XML markup of the page description program.
    Long answer: Adobe PostScript is a page description programming language, unlike Xerox Interpress which is a page and document description programming language. In other words, Adobe PostScript is a streaming or sequential rendering model that cannot simulate the behaviour of a bound book where the user can turn from any one page to any other page arbitrarily. Adobe introduced Acrobat Distiller in 1993 in order to convert Adobe PostScript page description programs into Adobe PDF page and document description programs that share the same fundamental functionality as Xerox Interpress.
    Conversion from Adobe PostScript to Adobe PDF buys one nothing but page-independent processing. Specifications published by Adobe in 1993 state how the SFNT Spline Font file format used by Apple and Microsoft for Unicode imaging has to be re-encoded into PostScript font program dictionary format (PostScript so-called simple fonts with less than 256 glyphs and PostScript so-called complex fonts (CID fonts) which are simple fonts tiled into a single superfont). All that is left is the glyph identifiers, and per Unicode Specification version 1.0 the glyph identifiers are private and font-dependent, so no character information can be inferred.
    ISO 19005:2005 PDF/A is a superset of ISO 15930:2002 PDF/X-3. The problem with ISO 15930:2002 PDF/X-3 is the same as above, that is, Adobe PostScript cannot encode the file format of the International Color Consortium, which has to be re-encoded to PostScript CSA Color Space Arrays and PostScript CRD Color Rendering Dictionaries. It is possible to encode the ICC file format directly in PDF 1.3 and higher, as specified in ISO 15930 and ISO 19005, but because PDF encodes only the glyph identifiers that are the output of the SFNT file format, and not the UCS Universal Character Set input and the settings for the feature selectors in the font file, ISO 19005:2005 has come under criticism for failing to support search in complex scripts.
    ISO 19005:2011 is supposed to address the shortcomings by saving the UCS input into the PDF itself, but in this case it is impossible to use Adobe PostScript and Adobe Acrobat Distiller as intermediates to Adobe PDF. So in order to drive ISO 19005:2011 Adobe would have to ditch Adobe Acrobat. I am not sure if there is software that implements ISO 19005:2011, but I noted that the Apple iBook Store does not accept PDF at all. Personally, I struggle to think of how to explain to endusers the overwhelming number of Adobe ISO PDF formats (there is PDF/E, PDF/UA and whatever else), and the overwhelming number of Adobe ISO PDF versions of these formats (there is ISO 19005:2005, ISO 19005:2011, ISO 15930 all the way back to 1999/2000 in God knows how many versions at this point).
    Best wishes,
    Henrik Holmegaard
    would-be technical writer

  • Any element with JAXB are always empty

    Hi guys!
    I'm trying to use the any element to specify some content for my web service. My XML schema contains this:
    <complexType name="casObject">
      <sequence>
        <element name="type"     type="string"/>
        <element name="key"          type="long"     nillable="true" />
        <any namespace="##targetNamespace" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
      </sequence>
    </complexType>I'm using jaxb 1.6 and it provides a method to get my any elements. In my example: List fieldList = casObject.getAny();
    The schema validation doesn't complain, the logging interceptor shows that the additional elements (from any element) are transfered, but the list is always empty. Any idea why this list is always empty?
    I've also have a question to the xsi:type element and jaxb in the web service forum called "missing xsi:type", maybe it it fits better in this forum. Please take a look.
    http://forum.java.sun.com/thread.jspa?threadID=743719&tstart=0
    Cheers,
    Ingo

    Hi Achim,
    According to my knowledge, there are no known problems with a "required Extended Protection" / "Always On" / "Livelink Server" combination.
    Extended Protection helps to prevent an authentication relay attack by using service binding and channel binding. We need to note that when Extended Protection is set to
    Required, only connections from protected applications on protected operating systems are accepted. This setting is the most secure but connections from operating systems or applications that do not support Extended Protection will not be able
    to connect to SQL Server. For more details, please review the following article.
    Connect to the Database Engine Using Extended Protection
    https://msdn.microsoft.com/en-us/library/ff487261(v=sql.110).aspx
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.
    Lydia Zhang
    TechNet Community Support

  • Remove XML element with JAXB

    Hi all,
    does anyone knows if it's possible to remove an xml element after that element has been set ? Using only jaxb if possible and not using other technology, for example DOM.
    I explain:
    umarshall car -->setOwner("me"); setSpeed("80"); -->marshall car
    will result into:
    <car>
    <owner>me</owner>
    <speed>80</speed>
    </car>
    I would like something that for example
    unmarshall car -->remove(speed); ....-->marshall car
    would result into:
    <car>
    <owner>me</owner>
    </car>
    could someone point out a way to do that ?
    thanks in advance...

    Okay, after peering over your code and trying a few things out I see one immediate problem and one possible improvement.
    The problem lies in this:
    1. if condition is true, remove item
    2. check recursively
    The problem is .. if an item is removed, the following recursive check will always fail. However, the entire loop is wrapped into a try..catch, so InDesign will not alert you that it failed. Instead, it will continue with what's after the loop, exactly because the try..catch is around the entire loop!
    Change the loop code to this
    if((elm.xmlElements[i].markupTag.name == "http") && (elm.xmlElements[i].parent.markupTag.name == "extlink"))
        var Store_CitAttri = elm.xmlElements[i].xmlAttributes.item("c_style").value;
        if(Store_CitAttri == "URL")
          elm.xmlElements[i].remove();
           foundtext = foundtext + 1;
           continue;
    Query_Remove(elm.xmlElements[i]);
    so the recursive checking is skipped. You can also remove the entire try..catch block, as this may hide additional errors ...
    The improvement is: as I started reading this thread from the top again, shouldn't you be removing the "extlink" items, rather than just the "http" ones inside?
    If so, remove the parent of the found item (which is always the "extlink"):
          elm.xmlElements[i].parent.remove();
    -- and, as this will break the loop (because you just removed the set of elements it was working in!), replace 'continue' with 'return'.
    Hope this helps

  • Creating Empty/Blank .mp3 with AIR

    Hello,
    Is it possible to create a blank or empty .mp3 file having specific duration using Adobe AIR?
    If it is possible, can any share the documentation and or code for the same.
    Thanks in advance.

    It is a comma deliminted File,, I did something,, I made sure that the ROOT should rotate as many times KONDAT has data . and KONDART IS in Segnent 4.
    Unnecessary space is no more there.
    Resolved by self.

  • Creating F01 form element on a page with different regions

    I have a HTMLDB page wherein there are about 5 different regions each having details for different modes of payment. For Ex: if mode of payments are cash, credit card and purchase order, I have 3 regions for these 3 modes each taking details like amount, credit card no.,expiry date etc...User can select more than 1 payment type.
    In order to know the different types selected by user, I want to create a form element with name F01 as page Item and use this as an array. For ex:if cash is chosen then F01(1)='cash',if Purchase order is chosen then F01(3)='po' etc....This I can inturn use in my pl/sql code to get the payment types chosen by looping thru the array of HTMLDB_APPLICATION.G_F01 element.
    Can somebody tell me if this is a fesible solution for what I am looking at or is there any other better solution.

    I have a HTMLDB page wherein there are about 5 different regions each having details for different modes of payment. For Ex: if mode of payments are cash, credit card and purchase order, I have 3 regions for these 3 modes each taking details like amount, credit card no.,expiry date etc...User can select more than 1 payment type.
    In order to know the different types selected by user, I want to create a form element with name F01 as page Item and use this as an array. For ex:if cash is chosen then F01(1)='cash',if Purchase order is chosen then F01(3)='po' etc....This I can inturn use in my pl/sql code to get the payment types chosen by looping thru the array of HTMLDB_APPLICATION.G_F01 element.
    Can somebody tell me if this is a fesible solution for what I am looking at or is there any other better solution.

  • Marshalling HashMap with JAXB 2.0 - empty tags & ill schema

    Hi all,
    I expected JAXB 2.0 to be capable to handle basic classes like HashMap, but it does not look so. I have two classes: SimpleNegotiationManager which has a property HashMap in which are stored the instances of SimpleInitiatedConversation:
    package xml;
    import javax.xml.bind.annotation.*;
    import java.util.HashMap;
    @XmlAccessorType(AccessType.FIELD)
    @XmlRootElement
    public class SimpleNegotiationManager {
        @XmlElement
        protected HashMap<String, SimpleInitiatedConversation> initiatedConversations;
        public SimpleNegotiationManager() {
        public HashMap<String, SimpleInitiatedConversation> getInitiatedConversations() {
            if (initiatedConversations == null) {
                initiatedConversations = new HashMap();
            return initiatedConversations;
        public void setInitiatedConversations(HashMap<String, SimpleInitiatedConversation> initiatedConversations) {
            this.initiatedConversations = initiatedConversations;
    }and
    package xml;
    import javax.xml.bind.annotation.*;
    import java.util.ArrayList;
    import java.util.List;
    @XmlAccessorType(AccessType.FIELD)
    @XmlType
    public class SimpleInitiatedConversation {
        @XmlElement
        protected List<String> messages;
        protected String conversationID;
        protected int protocolState;
        public SimpleInitiatedConversation() {
        public List<String> getMessages() {
            if (messages == null) {
                messages = new ArrayList();
            return messages;
        public void setMessages(List<String> messages) {
            this.messages = messages;
        public int getProtocolState() {
            return protocolState;
        public void setProtocolState(int protocolState) {
            this.protocolState = protocolState;
        public String getConversationID() {
            return conversationID;
        public void setConversationID(String conversationID) {
            this.conversationID = conversationID;
    }When I marshalled SimpleNegotiationManager while the HashMap was filled with several <String,SimpleInitiatedConversation> entries, in the output were empty tags initiatedConversations:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <simpleNegotiationManager>
      <initiatedConversations>
      </initiatedConversations>
    </simpleNegotiationManager>When I used schemagen to generate a schema, it produced:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="simpleInitiatedConversation">
        <xs:sequence>
          <xs:element name="messages" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>
          <xs:element name="conversationID" type="xs:string" minOccurs="0"/>
          <xs:element name="protocolState" type="xs:int"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="simpleNegotiationManager" type="simpleNegotiationManager"/>
      <xs:complexType name="simpleNegotiationManager">
        <xs:sequence>
          <xs:element name="initiatedConversations" type="hashMap" minOccurs="0"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="hashMap">
        <xs:complexContent>
          <xs:extension base="abstractMap">
            <xs:sequence/>
          </xs:extension>
        </xs:complexContent>
      </xs:complexType>
      <xs:complexType name="abstractMap" abstract="true"/>
    </xs:schema>Particularly the description of HashMap seems ill - there is not specified that the HashMap has keys String and values SimpleInitiatedConversation.
    Unfortunatelly, the j2s-xmlAdapter-field example available with JAXB 2.0 is more complicated than I need. I just need to store/load HashMap into/from XML and I do not care what it looks like. Is it possible to avoid extending XmlJavaTypeAdaptor for a simple storing a HashMap into XML? Perhaps I use improper annotations in the source code, but I cannot get it working. Any clue?

    Ok i figured out one way of doing this by using some classes from JAXP...
    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema s = null;
    try{
        s = sf.newSchema(new File("Sources/schema/test.xsd"));                    
    }catch(Exception e){
        System.err.println("Exception e: " + e.getMessage());
    marshaller.setSchema(s);
    //MyValidationHandler class implements the ValidationEventHandler interface
    MyValidationHandler gv = new MyValidationHandler();
    marshaller.setEventHandler(gv);If anyone has something to add let me know!!

  • Is there a way to modify the style sheet so that it transforms an XML document with empty tags as tag / ?

    I have extracted some code from codeproject to
    reindent an XML document. Does anyone know how I can modify the stylesheet to make it so that the transform of an XML file will result in empty tags showing up as <tag /> instead of <tag></tag>?
    // http://www.codeproject.com/Articles/43309/How-to-create-a-simple-XML-file-using-MSXML-in-C
    MSXML2::IXMLDOMDocumentPtr FormatDOMDocument(MSXML2::IXMLDOMDocumentPtr pDoc)
    LPCSTR const static szStyleSheet =
    R"!(<?xml version="1.0" encoding="utf-8"?>)!"
    R"!(<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">)!"
    R"!( <xsl:output method="xml" indent="yes"/>)!"
    R"!( <xsl:template match="@* | node()">)!"
    R"!( <xsl:copy>)!"
    R"!( <xsl:apply-templates select="@* | node()"/>)!"
    R"!( </xsl:copy>)!"
    R"!( </xsl:template>)!"
    R"!(</xsl:stylesheet>)!";
    MSXML2::IXMLDOMDocumentPtr pXmlStyleSheet;
    pXmlStyleSheet.CreateInstance(__uuidof(MSXML2::DOMDocument60));
    pXmlStyleSheet->loadXML(szStyleSheet);
    MSXML2::IXMLDOMDocumentPtr pXmlFormattedDoc;
    pXmlFormattedDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
    CComPtr<IDispatch> pDispatch;
    HRESULT hr = pXmlFormattedDoc->QueryInterface(IID_IDispatch, (void**)&pDispatch);
    if (SUCCEEDED(hr))
    _variant_t vtOutObject;
    vtOutObject.vt = VT_DISPATCH;
    vtOutObject.pdispVal = pDispatch;
    vtOutObject.pdispVal->AddRef();
    hr = pDoc->transformNodeToObject(pXmlStyleSheet, vtOutObject);
    //By default it is writing the encoding = UTF-16. Let us change the encoding to UTF-8
    // <?xml version="1.0" encoding="UTF-8"?>
    MSXML2::IXMLDOMNodePtr pXMLFirstChild = pXmlFormattedDoc->GetfirstChild();
    // A map of the a attributes (vesrsion, encoding) values (1.0, UTF-8) pair
    MSXML2::IXMLDOMNamedNodeMapPtr pXMLAttributeMap = pXMLFirstChild->Getattributes();
    MSXML2::IXMLDOMNodePtr pXMLEncodNode = pXMLAttributeMap->getNamedItem(_T("encoding"));
    pXMLEncodNode->PutnodeValue(_T("UTF-8")); //encoding = UTF-8
    return pXmlFormattedDoc;
    Or, if there is some other method for reindenting a MSXML2::IXMLDOMDocumentPtr object where I can specify how I want empty tags to be stored, that would be great too.  However, I don't want it to lose its status of an MSXML2::IXMLDOMDocumentPtr object.
     I.e. I would like to still perform operations on the result as if it was still an MSXML2::IXMLDOMDocumentPtr object.
    Thanks,
    A
    Adrian

    If anyone is interested, I got an answer on StackOverflow
    here.
    Adrian

  • I have tried to view videos created in premiere elements 10 and I get the following message: "this file type is not supported, or the required codec is  not installed.  When it opens there is a red screen in the monitor panel with Korean writing which als

    I have tried to view videos created in premiere elements 10 and I get the following message: "this file type is not supported, or the required codec is  not installed.  When it opens there is a red screen in the monitor panel with Korean writing which also appears in the place of each clip in the video.  I tried uninstalling and reinstalling premiere elements 10, but that did not have any effect on the video.  Do you have any suggestions?  I researched codec, but do not understand them at all.

    gloucester
    In case you did not find it, the following is a copy/paste of the Announcement on Premiere Elements 19/NVIDIA GeForce
    that appears at the top of this forum.
    Premiere Elements 10 NVIDIA Video Card Driver Roll Back
    If you are a Premiere Elements 10 user whose Windows computer uses a NVIDIA GeForce video card and you are experiencing
    Premiere Elements 10 display and/or unexplained program behavior, then your first line of troubleshooting needs to be rolling
    back the video card driver version instead of assuring that it is up to date.
    Since October 2013 to the present, there have been a growing number of reports about display and unexplained workflow
    glitches specific to the Premiere Elements 10 user whose Windows computer has a NVIDIA GeForce video card. If this applies
    to you, then the “user to user” remedy is to roll back the NVIDIA GeForce video card driver as far as is necessary to get rid of
    the problems. The typical driver roll back has gone back as far as March – July 2013 in order to get a working Premiere
    Elements 10. Neither NVIDIA nor Adobe has taken any corrective action in this regard to date, and none is expected moving forward.
    Since October 2013, the following thread has tried to keep up with the Premiere Elements 10 NVIDIA reports
    http://forums.adobe.com/thread/1317675
    Older NVIDIA GeForce drivers can be found
    http://www.nvidia.com/Download/Find.aspx?lang=en-us
    A February 2014 overview of the situation as well as how to use the older NVIDIA GeForce drivers for the driver roll back can be found
    http://atr935.blogspot.com/2014/02/pe10-nvidia-video-card-roll-back.html
    ATR

  • I want to create a HD disc with my Adobe Premier Elements but I am getting low resolution.  When I go to share the DVD to disc the form only offers 8pixels at the bottom.  How do I burn this DVD in HD with higher number of pixels?

    I want to create a HD disc with my Adobe Premier Elements but I am getting low resolution.  When I go to share the DVD to disc the form only offers 8pixels at the bottom.  How do I burn this DVD in HD with higher number of pixels?  I have read other forums on burning HD DVD's but I do not see the option to turn the 8 pi into 40 pi the one forum recommended.  I want my DVD to be HD so I may sell these videos online for my business.  I can't sell them the low quality they are burning now.  Hopefully you can help me.  Thanks.

    desalvom
    Thank you for your reply.
    You cannot burn your high resolution video that you can view on your computer to an AVCHD on DVD disc
    that will replay through a regular DVD player. But players are marketed under a variety of names with
    different support opportunities. One manufacturer may call its product MultiMedia Player, media player, Blu-ray player,
    etc.The bottom line is the specifications for each of the players that are candidates for the playback of
    the AVCHD format on DVD disc or the format of interest.
    If you upload your HD (1920 x 1080) video to YouTube, YouTube converts the video to flash format, but it goes up as the HD video.
    But, beware. Look at the YouTube viewing setting when your uploaded video is playing back. The YouTube default is not
    HD. It might be 360p, 480p. If you have a 1080p video, then before the YouTube playback, you should be looking
    at the video with the YouTube 1080p HD setting for best viewing. That is a YouTube matter.
    Best results depend on you
    a. setting up the Premiere Elements project preset to match the properties of the source media. That means, if
    you have 1080p source, you (manually) or the project (automatically) set the project preset at
    NTSC
    DSLR
    1080p
    DSLR [email protected]
    or the PAL counterpart, depending on your region need.
    b. if you upload your video to YouTube using the Premiere Elements feature, there is a HD preset, but you cannot
    customize it.....if you need customization, then you can export your Timeline to a file...in this example
    Publish+Share
    Computer
    AVCHD
    with Presets = MP4 H.264 1920 x 1080p30 or PAL counterpart
    and then customize the preset under the Advanced Button/Video Tab of that preset. In increase quality, you might look to increase
    the Bitrate under Advanced Button/Video Tab settings - without compromising the file size.
    Then you would upload that file to YouTube at the YouTube web site.
    All of the above are factors that need looking into in order to determine the why for what you wrote
    I have published a shortened advertisement video to YouTube- say 5 minutes-
    and it is low quality
    Often SD video upscaled to HD can present poorly. But, you are dealing with a HD workflow so that should not be introduced into the matter. The setup of the project and
    the properties of the source video are important, but let us start with the above and rule in or out those considerations first.
    Thank you. As always, any clarification needed, please do not hesitate to ask.
    ATR

  • How to create an element with an ID attribute ?

    Hi,
    first i need to say i searched the web for ~one week now, and couldn't find any good solution.
    Lastly i searched into this forum and, unfortunaly, i couldn't find any good answers to the problem.
    Here are the reference :
    http://forum.java.sun.com/thread.jsp?forum=34&thread=290862 < it's exactly the pb, no answers
    http://forum.java.sun.com/thread.jsp?forum=34&thread=338022 < no answers
    http://forum.java.sun.com/thread.jsp?forum=34&thread=67747 < answer is false
    http://forum.java.sun.com/thread.jsp?forum=34&thread=67683 < same pb, wrong answer
    http://forum.java.sun.com/thread.jsp?forum=34&thread=470003 < a bit far form the initial subject
    so i'll be quick :
    - when you load ur xml DOM, u can use the 'getElementById()' method, and it works very well
    - but when u create a new Element, u can't use the simple 'setAttribute()' method because as said in the doc : "Because the DOM Core is not aware of attribute types, it treats all attribute values as simple strings, even if the DTD or schema declares them as having tokenized types.", therefore, the 'getElementById()' can't work with those newly created Element.
    - same pb arise when u try to modify an ID attribute...
    so, with my investigation, i found that u need to specify to the DOM that the attribute you just set is an 'ID'.
    and that's where i have problems, i tried creating EntityReference and binding that node to the attribute node, the element node and even to the Textnode but couldn't find anything to work...
    Here is my method (which doesn't work) :
    public void setIdAttribute(Element element,String nameAttribut, String dataAttribut)
                    System.out.println("setIdAttribute() : nameAttribut="+nameAttribut+" dataAtribut="+dataAttribut+" user="+element.toString()); //DEBUG
                    Attr attributRef = document.createAttribute(nameAttribut);
                    EntityReference er = document.createEntityReference(nameAttribut); //creating an Reference for the attribute named 'nameAttribut'
                    Text data = document.createTextNode(dataAttribut);
                    //link to the main DOM tree
                    attributRef.appendChild(data); //adding the String data
                    attributRef.appendChild(er); //...then telling DOM that the attribute 'nameAttribut' is an ID
                    //at last linking the attribute node
                    element.setAttributeNode(attributRef);
            }I'm totally lost :/ (help !)
    AciD

    After thinking about it some more, I find that adding a setIdAttribute() method in a DOM level 3 conformant way while at the same time keeping it independent of a particular DOM implementation would take quite some effort. It's easier to add similar functionality into a Document wrapper along these lines:
    public class MyDocument implements Document {
       private Document _doc;
       private Map _eltsById = new TreeMap();
       public MyDocument(Document doc){
          _doc = doc;
       public Element getElementById(String id){
          Element foundElt = _doc.getElementById(id);
          if (foundElt == null)
             foundElt = (Element)_eltsById.get(id);
          return foundElt;
       public void setIdAttribute(String attrName, Element elt){
          String attrValue = elt.getAttribute(attrName);
          if (attrValue != null)
               _eltsById.put(attrValue, elt);
       //...implement all the other Document methods by forwarding to _doc
    test(){
       MyDocument myDoc = new MyDocument(parse(...));
       Element elt = myDoc.createElement(...);
       elt.setAttribute("id", "123");
       myDoc.getDocumentElement().appendChild(elt);
       myDoc.setIdAttribute("id", elt);
       Element foundElt = myDoc.getElementById("123");
       assert elt == foundElt;
    }Unfortunately this simple implementation breaks down if an ID attribute value is later changed, so this is probably a rather dirty hack.
    Some DOM implementations allow you to search for nodes using implementation specific methods or XPath. Oracle's XML does it like this:
    XMLDocument doc = parse(...);
    Element elt = (Element)doc.selectSingleNode("//*[@id='123']");
    Or like this with Xalan:
    CachedXPathAPI xpath = new CachedXPathAPI();
    Element elt = (Element)xpath.selectSingleNode(doc, "//*[@id='123']");
    The XPath based ways of searching for nodes have the benefit of not being dependent on schema validation in the first place (as the ID based mechanisms are). And of course you have many more search options than just attribute values. On the other hand XPath evaluation is hugely slower than most getElementById implementations if it doesn't use some kind of index. So if you want fast (that is index based) XPath queries for in memory XML data, you should probably look at something like XQEngine http://xqengine.sourceforge.net/
    -Alexander

  • How to create the default empty work book with company logo and address????

    Hi Guru's
    I am working in ECC5.0 (BW 3.5), i wann create the default empty work book with company logo and company address. so when i am executing any query's that should open in the default empty work book.
    greatly appreciated your help. will assign pt's for sure.
    thanks and regards
    Mohan

    Hi Mohan,
      Report designer is used in BI 7.It is a seperate application used for formatting
    the report.
    For BW3.5,go through this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/33/746e393cf65c1ae10000000a114084/frameset.htm
    This would help you
    Regards,
    Senoy

  • COPA unable to create as charac data element with LIFNR as domain HELP ASAP

    Hi
    We had a data element created with KUNNR as domain.
    We added to PAPARTNER STRUCUTRE and created as characteristics in our operating concern.
    Now there is a need to change to LIFNR as domain instead of KUNNR.
    There we created a new dala element with LIFNR as domain and added to PAPARTNER
    structure and when we tried to create them as characterisc system did not let us transfer to
    our operating concern.
    We do not know why we are unable to create this characterisic.
    When we tried to create the characteristic it was shown under 'Transfer from'
    But when we wanted to move right to left it was shown under 'grey' status and not ready for transfer.
    We need a solution very urgent and any help is greatly appreciated.
    Thanks
    Raj

    Hi
    KEA0 - Display Data Structure
    Now, Extras > Chars > Unlock
    after this try to push from right to left
    br, Ajay M

  • How to create XML element with out creating a document

    I ve been looking for hours for a method to create an XML element without the need for the Document. I am trying to create objects that access the database, and I need in each of these objects a method that returns only an element (ie. getXMLData()). And in the class that created these object, I nee to call the getXML() methods and construct a document. However, I am not looking to create the document if I am not going to use it. In the component class I need to be able to traverse the xml element and read and modify the values. Is there a way to do so with sun's JDK ?

    I ve been looking for hours for a method to create an
    XML element without the need for the Document.
    ... I am not looking to create the document if I
    am not going to use it.Hi M-A,
    Though you have been told the solution, let's stick to your original issue, just for the sake of interest. I gather what you have in mind is finding the answer to the following question: is there a way of creating a document without having to bind it to any data source? The answer is yes. What you might need is the createDocument() method of the DOMImplementation interface which offers lightwight document handling by obviating the need to construct a particular DOM instance. (You could also use the getDOMImplementation() method of the DOMImplementationRegistry interface, but it has bugs.) Here's a sample code:DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser = factory.newDocumentBuilder();
    DOMImplementation domImpl = parser.getDOMImplementation();
    Document doc = domImpl.createDocument(null, "rootnode", null);The above code produces the following document:<?xml version="1.0" encoding="UTF-8"?>
    <rootnode/>You can make this document even skinnier if you pass null values to all three parameters of the createDocument() method, in which case the document will only contain the prolog. I think both the creation and the structure of this document are simple enough for you to use it as some sort of utility (e.g. by putting the code in a separate class) for creating elements.

Maybe you are looking for

  • Uploading iWeb *****

    Ok here is the problem that keeps bugging me since day 1 with iWeb but now it seems to be permanent: Every time when I upload my pages it gives me an error. However when I check the page on the internet it all seems to be there and working fine. Prob

  • Virtual User Minutes in Visual Studio Online Account Not Updating

    Dear Team, I have conducted a LoadTest connecting to my VSO account and even after completing the test under Resource Usage section I'm not able to see my VUM(Virtaul User Minute) usage changing. Its always 0. Please help me with it. Regards, Divin

  • Why my 2 Canon Pixma show a banding issue?

    Hi since I have an iMac my photos showed a severe banding especially in the sky area. I don't mean it's a Mac problem, but probably the driver I have is not properly optimized. It happened since the beginning (Snow Leopard) and with a Canon Pixma iP4

  • Using an external microphone when recording in iMovie?

    I've been trying to find a way to use my external USB microphone (MXL 990 USB) when recording a movie into iMovie when in the Camera Import window. I have the option to use it when I go under the Voiceover menu, but I can't find anything in iMovie or

  • Problem Table maintanance generator

    Hi,   can somebody please give me the solution.i created table maintanance in crm but it is not taking 'raw' data type field how can i solve this problem i want to add this field also. Regards, sivakumar.