Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: retain newline when copying contents of attribute >Thread Next - Re: retain newline when copying contents of attribute Re: retain newline when copying contents of attributeTo: NULL Date: 3/3/2006 7:47:00 AM Hi Martin -
Thanks for the suggestion. Maybe I implemented it incorrectly -- it
appears that (at least inXselerator) the content of an attribute is
normalized automatically when you select it. This doesn't happen to the
content of an element. Here's my test:
The xml:
<a>
<b x="111" y="222
333">44
55</b>
</a>
The xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
1.1. @/a/b/@y selected into a variable:
<xsl:variable name="y" select="a/b/@y"></xsl:variable>
<pre>
<xsl:value-of select="$y"/>
</pre>
:/a/b/@y selected into a variable
<br/>
<br/>
2.1. /a/b selected into a variable:
<xsl:variable name="b" select="a/b"></xsl:variable>
<pre>
<xsl:value-of select="$b"/>
</pre>
:/a/b selected into a variable
<br/>
<br/>
</xsl:template>
</xsl:stylesheet>
And the result:
1.1. @/a/b/@y selected into a variable:
<pre>222 333</pre>
:/a/b/@y selected into a variable
<br><br>
2.1. /a/b selected into a variable:
<pre>44
55</pre>
:/a/b selected into a variable
<br><br>
My goal, however, is to get the following for 1.1:
1.1. @/a/b/@y selected into a variable:
<pre>222
333</pre>
:/a/b/@y selected into a variable
<br><br>
-------
(Later) I've done a bit more research, and now think that I won't be
able to achieve my goal directly via XSL. According to the XSL
standard, an attribute's content is _always_ normalized, and there's no
way to act on its non-normalized state. So I think I'm stuck. I think
I'll have to write a filter that transforms
<a>
<b x="111" y="222
333">44
55</b>
</a>
to
<a>
<b x="111"> <y>222
333</y>44
55</b>
</a>
and then feed that to a stylesheet that copies the element y.
Do you agree?
Thanks,
- Don
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
