webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

"&" causes JDOMException

  • 1.  "&" causes JDOMException

    Posted Fri November 22, 2002 11:21 AM

    Gentlemen, I have XML files that look like this:

    bla
    anything &

    If they dont contain an ampersand I can parse them to TXMLObjects and insert them in my Tamino DB, else I retrieve an Exception:<BR>org.jdom.JDOMException: Error on line 1: The entity name must immediately follow the '&' in the entity reference.<BR> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:407)<BR> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:499)<BR> <BR>The Exception is caused in the following JavaCode:<BR><BR>Document document = saxBuilder.build( new StringReader(getXmlStringBuffer().toString()) ); <BR><BR>I read Bill Leeneys post from 08 Nov 2002 14:19, however I need further Instructions.

    Thank you


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 2.  RE: "&" causes JDOMException

    Posted Fri November 22, 2002 11:30 AM

    This isn’t really the same issue as the post you refer to. The ampersand character is not valid in xml element content and needs to be escaped. See the following quote from w3c:

    The ampersand character (&) and the left angle bracket (<) may appear in their literal
    form only when used as markup delimiters, or within a comment, a processing instruction, or a 
    CDATA section. If they are needed elsewhere, they must be escaped using either numeric character
    references or the strings "&" and "<" 


    Unescaped ampersands are assumed to be the start of an entity name, and hence the text of your error.
    HTH


    #webMethods-Tamino-XML-Server-APIs
    #API-Management
    #webMethods