[jdom-interest] Parsing a comment like <!--- Hello
Jason Hunter
jhunter at xquery.com
Tue Nov 2 16:47:48 PST 2004
Yes, by my reading too it looks like a simple Verifier bug. We'll fix
it. Elias, for now you can just remove that if statement and recompile.
-jh-
Dennis Sosnoski wrote:
> That does match the production given in the XML recommendation, so it is
> valid XML:
>
> Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
>
> The problem is that third "if" in the code, which returns "Comment data
> cannot start with a hyphen." - according to the above production,
> comment data *can* start with a hyphen, providing the hyphen is followed
> by a non-hyphen. Surprised me!
>
> - Dennis
>
> Elias Ross wrote:
>
>> Somebody created a configuration file with a comment like this
>>
>> <!--- This is a comment -->
>>
>> It passed validation with xmllint. JDom however will *not* parse this
>> comment. (This is valid XML, by the way.)
>>
>> What happened was we tried to read this configuration file and blew up
>> unexpectedly. JDom and xmllint (and other XML parsers) should agree.
>>
>> src/java/org/jdom/Verifier.java:485
>>
>> public static String checkCommentData(String data) {
>> String reason = null;
>> if ((reason = checkCharacterData(data)) != null) {
>> return reason;
>> }
>>
>> if (data.indexOf("--") != -1) {
>> return "Comments cannot contain double hyphens (--)";
>> }
>> if (data.startsWith("-")) {
>> return "Comment data cannot start with a hyphen.";
>> }
>> if (data.endsWith("-")) {
>> return "Comment data cannot end with a hyphen.";
>> }
>>
>> // If we got here, everything is OK
>> return null;
>> }
>>
>>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list