Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: retain newline when copying contents of attribute

From: "dkacher" <donald.kacher@------.--->
To: 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



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent