anyURI validation failing in Xerces-J

D

dfielder

I'm using the latest version of Xerces-J and parsing an XML file using
the 'org.apache.xerces.parsers.SAXParser' parser. The problem I have
is that a value such as 'file:///c:/#test#.jpg' is failing validation
as xs:anyURI. What's interesting is that if I remove one of the pound
signs, it validates just fine. The string with two pound signs
validates with no problem in XMLSpy. Any ideas what's going on here?
Here's the exact error coming out of the SAXParser:

[Error] test.xml:9:48: cvc-datatype-valid.1.2.1:
'file:///c:/#test#.jpg' is not a valid value for 'anyURI'

If this is the wrong area to post this question, please let me know a
more suitable place. Thanks for any help in advance.
 
R

Richard Tobin

[Error] test.xml:9:48: cvc-datatype-valid.1.2.1:
'file:///c:/#test#.jpg' is not a valid value for 'anyURI'

The # symbol is used to separate the main part of a URI from the fragment
identifier, for example http://www.w3.org/TR/REC-xml/#sec-intro.

You need to encode your # characters as %23:

file:///c:/%23test%23.jpg

The reason it works if you remove, say, the second # is that it is
interpreting it as the test.jpg fragment of file:///c:/.

-- Richard
 
J

JAPISoft

May be I miss something, but shouldn't it be : file://c:/#test#.jpg ?
And also I think the # caracter is maybe reserved (this is anchor for
sample with HTML and it is at the end part of the URL).

Best regards,

A.Brillant
EditiX - XML Editor and XSLT Debugger
http://www.editix.com
 
R

Richard Tobin

JAPISoft said:
May be I miss something, but shouldn't it be : file://c:/#test#.jpg ?

No, it's an example of file://hostname/... where the hostname
part is empty.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top