Hi David Thanks for the vote of confidence :-)
By using insertChars() you are telling XmlBeans that you want to insert text. To insert text which includes a '<' character the XML spec insists that the '<' character _must_ be translated into < (see http://www.w3.org/TR/REC-xml/ section 2.4 and the mailing list response I sent yesterday at http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200601.mbox/%3c99 [EMAIL PROTECTED] regarding a similar issue with '&'). If you need to keep this approach (i.e. treating the '<' as text) then you have no choice - the XML spec insists that if you send a '<' character as part of text data it must be translated to < and it is then the responsibility of whatever is receiving the XML to translate back to '<'. But it sounds like you really want to include <delimiter/> as markup and not as text. If you have a schema then you must update it to allow this. Once you've done this then you need to use insertChars() to insert the text and beginElement() to insert the markup. The following should work: QName delimQName = new QName("yourNamespace", "delimiter"); cursor.insertChars("123 Bogus Street"); cursor.beginElement(delimQName); cursor.toNextToken() cursor.insertChars("Apt 456"); cursor.beginElement(delimQName); cursor.toNextToken() beginElement() leaves the cursor positioned between the start and end tokens (and note, both these tokens are there even if the representation is the empty element <delimiter/>) so you need to do a toNextToken() to get beyond the END token - see http://xmlbeans.apache.org/documentation/tutorial_getstarted.html#Gettin g+Started+with+the+XML+Cursor and http://xmlbeans.apache.org/docs/2.0.0/guide/conNavigatingXMLwithCursors. html for details). You may end up with "123 Bogus Street<delimiter></delimiter>" instead of "123 Bogus Street<delimiter/>" - unfortunately I don't think there's any way to force XmlBeans to use the latter approach - but I'm open to contradiction if someone knows better. However all XML processors should recognize the two as equivalent. Cheers, Lawrence > -----Original Message----- > From: Bartlett, David HLTH:EX [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 01, 2006 12:36 PM > To: [email protected] > Subject: xml delimiters > > Hi, > > Im relatively new to xmlbeans. We have a new project that uses a > number > of complex xsd's. We started looking into JAXB but abandoned it when we > found it > couldnt handle the complexity. Xmlbeans was by far the only one that could > handle our xsd's. > However, there is one minor item that I am having problems with. > > We have an address complex type comprised of the usual child > elements (city, postal code, etc). > The problem is that to handle address lines we are required to use > delimiters. > > <Addr> > 123 Bogus Street<delimiter/> > Apt 456<delimiter/> > <city>Anywhere</city> > <postalcode>1a2b3c</postalcode> > </Addr> > > For incoming xml documents I can extract the delimiter values using > xml cursor. However, > I cant figure out how to create the delimiters for outgoing xml documents. > If I use the insertelement > method of xmlcursor it creates the standard element > > <delimiter>123 Bogus Street </delimiter> > > which we dont want. If use the insertChars method of xmlcursor to > insert the > text and closing tag > > insertChars("123 Bogus Street<delimiter/>") > > It converts the "<" into < so the end result looks like the > following (odd that it doesnt conver the > as well). > > 123 Bogus Street<delimiter/> > > Does anyone know how I can create my delimter element? > > > David Bartlett > IT Advisory Professional > Contracted Resource to: Managed Operations, KMT > Ministry of Health > Tel: (250) 952-6462 Fax: (250) 952-6893 > Email: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

