XSL Extracting Ampersand from XSD

J

james.eaton

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.
 
J

Joseph Kesselman

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.)
 
J

james.eaton

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.)
 
J

Joseph Kesselman

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.
 
J

Joseph Kesselman

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
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top