xsl-list
[Top] [All Lists]

Re: identity transform - include CDATA's, etc

2003-07-08 12:41:31
the reason I wanted the <![CDATA[]]> to come out in the output is that output of the identity transform is supposed to undergo another xslt transform.

In that case you _definitely_ don't mind.

<![CDATA[ <a>b</a>]]>

and

&lt;a>b&lt;a>

are _identical_ as far as XSLT is concerned.

ok, but these 2 lines are not identical to
<a>b</a>

if my testing is correct.  And this is where the problem is.

if the identity transform outputs:
&lt;a>b&lt;a>
this is fine, but if it outputs:
<a>b</a>
this is not, as it could obviously run into problems when the '<' signs aren't xml but something else (eg javascript code). in this case, the source document would be valid xml b/c of the CDATA beginning and end markers, but the output would not be.

I tested saxon and msxsl using the identity transform on jscript.xml:
<?xml version="1.0" encoding="utf-8"?>
<docroot>
  <a>
   <![CDATA[ if( x < y ) alert(); ]]>
  </a>
</docroot>

and it output:
<?xml version="1.0" encoding="utf-8"?>
<docroot>
  <a>
   if( x &lt; y ) alert();
  </a>
</docroot>

so this would be good if this is the way '<' signs in CDATA sections are always handled, and if this behavior is reliable and predictable. but is it, in fact, reliable across the multitude of xslt processors and other circumstances? Is it part of the xslt spec? I had understood that other behaviors similar to this one are not reliable.

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list