Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with square brackets in xml file

843834Sep 20 2006 — edited Sep 21 2006
Hi

I have an xml file containing the following tag
<custom name="custom1">
    <value>acqTypeMaxNumber[Line](plot);imageSelection[Line](plot);imagePositionSet1[Line];imagePositionSet2[Line];imageSet[Surface]</value>
</custom>
Previously I was using j2se 1.4.7, and this was not a problem to parse.
Now, after uprading to j2se 5.0, this can no longer be parsed.
I am using a class with the following structure for the parsing:
public class SaxParser extends DefaultHandler {

    public static void parseXmlFile(File input, String schemaLoc, DefaultHandler handler)  throws Exception {
		
            // Create a builder factory           
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(true);
            
            // Create a parser and parse the xml file.
            SAXParser parser = factory.newSAXParser();            
            parser.parse(input, handler);
    }

    public void startElement(String namespaceURI, String localName,
                             String qName, Attributes atts)  {
            // Do stuff
    }

    public void characters(char[] buf, int offset, int len) throws SAXException {
        name = new String(buf, offset, len).trim();
            // Do stuff
    }

    public void endElement(String namespaceURI, String sName, String qName) throws SAXException {
            // Do stuff
    }

    private void setAttributes(SchemaElement e, Attributes atts) {
            // Do stuff
    }
    
    private boolean anyNextToFound(String name) {
            // Do stuff
    }    
}
What I see is that the characters method is being called once for every square bracket in the value tag, and once for all characters after and before the square bracket.

I have tried, without success, to write the tag using CDATA, i.e. looking like this:
<value>![CDATA[acqTypeMaxNumber[Line](plot);imageSelection[Line](plot);imagePositionSet1[Line];imagePositionSet2[Line];imageSet[Surface]]]</value>
I have searched a lot on the internet without finding anything concerning this problem.
Does anyone have a clue of what's going on here?

Any help at all is appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 19 2006
Added on Sep 20 2006
2 comments
1,016 views