Project

Profile

Help

Issue with square brackets

Added by Anonymous over 15 years ago

Legacy ID: #7123896 Legacy Poster: Jon Combe (joncombe)

I am trying to use XSLT and Saxon to parse an XML document containing the name of some XML files. In some cases I then need to open the files and use XSL to parse elements out of those documents. I store the name of the document in a variable called $thisdoc and then access it with document like this document($thisdoc)/path/to/element This works well in most cases except when the file name contains square brackets. For example report[1].xml Internet Explorer often adds these [1], [2] etc to filenames, for example. In this case the XSL always fails with this error FODC0002: Exception thrown by URIResolver: Invalid relative URI {<filename>}: Illegal character in path at index 41: Where the index is the character position in the filename of the opening square bracket. As I understand it square brackets [] do not have to be escaped in XML and since I can't change the actual filenames I am stuck as how to resolve this. Do I have to put something special in my XSL to allow it to cope with text containing square brackets? Thanks Jon


Replies (1)

RE: Issue with square brackets - Added by Anonymous over 15 years ago

Legacy ID: #7124970 Legacy Poster: Michael Kay (mhkay)

The argument to the document() function is a URI, not a filename. A URI cannot contain square brackets, I believe: the brackets should be escaped as %5B and %5D. Try converting the name to a URI using the iri-to-uri() function.

    (1-1/1)

    Please register to reply