Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#10 comment in xml= attribute causes SAXParseException

closed
nobody
None
5
2007-10-31
2007-02-13
smurfer
No

Trying to insert a comment with the xml="<!-- comment sting -->" attribute causes and error.

<xmltask dest="lines.xml"
failWithoutMatch="true"
indent="true"
standalone="true"
outputter="simple:3"
report="false">
<insert path="/root"
position="under">
<![CDATA[
<root>
</root>
]]>
</insert>
<insert path="/root"
position="under"
xml="&lt;!-- test comment --&gt;">
</insert>
</xmltask>

returns the following stack dump:

BUILD FAILED
/ipms/plati/MMSdbmgmt/patches/build.xml:38: The string "--" is not permitted within comments.
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:225)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:138)
at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:96)
at org.apache.tools.ant.Main.runBuild(Main.java:683)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.scanComment(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanComment(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:209)
... 6 more

Discussion

  • smurfer
    smurfer
    2007-02-13

    Logged In: YES
    user_id=1718666
    Originator: YES

    I did a quick fix this issue in file "com/oopsconsultancy/xmltask/output/FormattedDataWriter.java":

    public void startDocument() throws SAXException {
    reset();
    String encoding = transformer.getOutputProperty(OutputKeys.ENCODING);
    String standalone = transformer.getOutputProperty(OutputKeys.STANDALONE);
    write("<?xml version=\"1.0\" " + (encoding == null ? "UTF-8" : "encoding=\""
    +encoding+"\" ") + "standalone=\""+standalone+"\"" + "?>\n\n");
    }

     
  • Brian Agnew
    Brian Agnew
    2007-02-14

    Logged In: YES
    user_id=521055
    Originator: NO

    Given the above I can't replicate this (note that I had to change the above for the first insert to insert to '/'). I DO get the above error if I change the inserted comment to xml="&lt;!-- -- test comment --&gt;" (which is what I'd expect and correct behaviour).

    Note the below fix is not related. The below IS incorporated in 1.14.1 however.

     
  • Brian Agnew
    Brian Agnew
    2007-10-31

    • status: open --> closed