XSL Extracting Ampersand from XSD

james.eaton

Usenet Archive
Joined
Oct 19, 2006
Messages
2
Reaction score
0
I have an XML Schema Document (.xsd) that contains documentation tags (specifically, custom tags subordinate xsd:appinfo). These documentation tags contain strings that may contain ampersands. I have written an XSL Document (.xls) to extract these values and output an XML document including them on the screen. When I copy and paste the result to an XML file (.xml) and test for well-formedness, I get an error telling me that a semicolon (;) is required after the text that follows the ampersand. This is because the parser is expecting an escape code. Is there a way to extract this information and translate the ampersand to & so that the resulting .xml document will be well formed? I have tried using translate($var, '&', '&amp') but it just balks at the first ampersand.
 

Joseph Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
733
Reaction score
0
documentation tags contain strings that may contain ampersands

If there's an ampersand in your input document which is used for anything other than an entity reference or a character reference, and is not within a <[CDATA]> section, the document is not legal XML.

Convert the ampersands to &amp; *BEFORE* asking XML tools to process this data. (I'm of the opinion that <[CDATA]> causes more problems than it solves, and should be used only as a lazy man's solution when hand-editing XML.)
 

james.eaton

Usenet Archive
Joined
Oct 19, 2006
Messages
2
Reaction score
0
My understanding is that, within appinfo tags, any information is considered extraneous data not processed by the XML processor. Hence, why it is allowed to be in the source document and still be valid.

However, your point still stands. If it is not valid in the context of the processable portion of an XML document, I suppose the XML parsing tools can not be expected to handle it.

Joseph said:
documentation tags contain strings that may contain ampersands

If there's an ampersand in your input document which is used for anything other than an entity reference or a character reference, and is not within a <[CDATA]> section, the document is not legal XML.

Convert the ampersands to &amp; *BEFORE* asking XML tools to process this data. (I'm of the opinion that <[CDATA]> causes more problems than it solves, and should be used only as a lazy man's solution when hand-editing XML.)
 

Joseph Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
733
Reaction score
0
My understanding is that, within appinfo tags, any information is considered extraneous data not processed by the XML processor. Hence, why it is allowed to be in the source document and still be valid.

Validity is only tested after well-formedness is stested -- and an isolated & is not well formed XML.
 

Joseph Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
733
Reaction score
0
My understanding is that, within appinfo tags, any information is considered extraneous data not processed by the XML processor. Hence, why it is allowed to be in the source document and still be valid.

Validity is only tested after well-formedness is tested -- and an isolated & character is not well formed XML.
 

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

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top