By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

XSL Extracting Ampersand from XSD

P: n/a
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.

Oct 19 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ja*********@gmail.com wrote:
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.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 19 '06 #2

P: n/a
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 Kesselman wrote:
ja*********@gmail.com wrote:
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.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 19 '06 #3

P: n/a
ja*********@gmail.com wrote:
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.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 19 '06 #4

P: n/a
ja*********@gmail.com wrote:
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.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.