> XmlCursor c = xmlo.newCursor();
> c.toFirstContentToken();
> String s = c.getTextValue();
> c.dispose();
 
Thanks for your reply. But how can I get next characters sequence? I
implemented code which tracks number of START/END (depth) and only takes
those which have depth=0 but I used code like this (with code you provided I
don't know how to get text which split into several sequences):
 
        int depth = 0;
        XmlCursor cursor = attr.newCursor();
        StringBuffer value = new StringBuffer();
        
        while (!cursor.toNextToken().isNone()) {
            if (cursor.currentTokenType() == XmlCursor.TokenType.START) {
                depth++;
            } else if (cursor.currentTokenType() == XmlCursor.TokenType.END)
{
                depth--;
            } else if (depth == 0 && cursor.currentTokenType() ==
XmlCursor.TokenType.TEXT) {
                String str = cursor.getChars().trim();
                
                if (str != null && str.length() > 0) {
                    value.append(str);
                }
            }
        }
        
        return value.length() == 0 ? null : value.toString();
 
 
  _____  

From: Lawrence Jones [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 27, 2006 10:41 PM
To: [email protected]
Subject: RE: Help needed with mixed content...
 
Hi Pavel
 
The content model you are referring to is called a "mixed" content model.
You specify this in your schema using the mixed="true" attribute: either
 
<complexType : mixed="true" >
 :
</complexType>
 
Or
 
<complexType>
  <complexContent mixed="true">
    :
  </complexContent>
</complexType>
 
See the schema spec
(http://www.w3.org/TR/xmlschema-1/#Complex_Type_Definitions) for details.
 
If you use XmlBeans on a schema like that then we do not generate a
gettter/setter for the text which may (or may not) be inside the element in
the instance doc. Instead you use the XmlCursor APIs. Once you have an
XmlObject (xmlo) do something like this:
 
XmlCursor c = xmlo.newCursor();
c.toFirstContentToken();
String s = c.getTextValue();
c.dispose();
 
The following links may also be useful to you:
 
http://xmlbeans.apache.org/documentation/tutorial_getstarted.html (the part
labelled "Getting Started with the XML Cursor" near the bottom)
http://xmlbeans.apache.org/docs/2.0.0/guide/conNavigatingXMLwithCursors.html
http://dev2dev.bea.com/pub/a/2003/11/traut.html
 
Cheers,
 
Lawrence
 
  _____  

From: Pavel Krupets [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 26, 2006 2:12 AM
To: [email protected]
Subject: Help needed with mixed content...
 
Hello,
 
I need to implement something like this:
 
<attribute name=":" class=":">
  <attribute name=":">value</attribute>
  <attribute name=":">value</attribute>
/attribute>
 
and 
 
<attribute name=":">value</attribute>
 
What I mean is that attribute element can contain sub elements OR text. What
do I need to use to implement this? Note that I need to read document (it
will be typed manually by user).
 
With regards,
Pavel Krupets
_______________________________________________________________________

Notice:  This email message, together with any attachments, may contain

information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated

entities,  that may be confidential,  proprietary,  copyrighted  and/or

legally privileged, and is intended solely for the use of the individual

or entity named in this message. If you are not the intended recipient,

and have received this message in error, please immediately return this

by email and then delete it.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to