RE: Xmlbeans is able to retrieve extra attribute from xml ?

Cezar Andrei <[email protected]>
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <19674e8b-5f41-4d6f-a445-8fb7e8bf8f4f@default>
It's probably because the document is not a well formed XML document.

 

Cezar

 

  _____  

From: Sebastien Dionne [mailto:[email protected]] 
Sent: Wednesday, December 23, 2009 11:17 AM
To: [email protected]
Subject: Re: Xmlbeans is able to retrieve extra attribute from xml ?

 

thanks, but why do I obtain a exception CDATA when I parse a xml that contains more data then the schema ?

RootDocument root = RootDocument.Factory.parse(new File("./src/test/resources/

RootDevice.xml"));
System.out.println(root.toString());

Exception in thread "main" org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA
    at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3486)
    at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:712)





2009/12/23 Cezar Andrei <HYPERLINK "mailto:[email protected]"[email protected]>

Sebastien,

 

It is possible, please check the XmlCursor interface. On the xmlbeans object you have the attributes, call:

XmlCursor xc = xobj.getCursor(); . Move the cursor around with xc.toFirstAttribute(); xc.toNextAttribute();

And get info on the current token, in your case the attribute: xc.getName xc.getTextValue, and when you're done call xc.dispose().

 

Cezar

 

  _____  

From: Sebastien Dionne [mailto:HYPERLINK "mailto:[email protected]" \[email protected]] 
Sent: Wednesday, December 23, 2009 7:10 AM
To: HYPERLINK "mailto:[email protected]" \[email protected]
Subject: Xmlbeans is able to retrieve extra attribute from xml ?

 

I have a simple question.



I have a xsd standard (string..no complextype).

I receive xml message that can contains extra attributes that are not in the xsd.

With JAXB they are put into 

    /**
     * Gets a map that contains attributes that aren't bound to any typed property on this class.
     * 
     * <p>
     * the map is keyed by the name of the attribute and 
     * the value is the string value of the attribute.
     * 
     * the map returned by this method is live, and you can add new attribute
     * by updating the map directly. Because of this design, there's no setter.
     * 
     * 
     * @return
     *     always non-null
     */
    public Map<QName, String> getOtherAttributes() {
        return otherAttributes;
    }

but is it possible to do something similar with xmlbeans ?

It a showstopper if I can't do that.

thanks


-- 
-------------
A+

Sébastien.

Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant




-- 
-------------
A+

Sébastien.

Vous pouvez me suivre sur Twitter / You can follow me on Twitter : http://twitter.com/survivant
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.