xsl-list
[Top] [All Lists]

RE: placing XML inside node attribute

2002-11-19 10:01:26
I'm afraid that this is invalid XML; you cannot put the < character
within an attribute.

-----Original Message-----
From: lpmlabs9(_at_)netscape(_dot_)net 
[mailto:lpmlabs9(_at_)netscape(_dot_)net] 
Sent: 19 November 2002 16:48
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] placing XML inside node attribute


I'm trying to place XML into the attribute of a tag as follows:

xml
<stock><ticker>ibm</ticker><high>100</high><low>95</low></ticker></stock


desired result
<object code="tickerplot.class">
<param name="xml"
value="<stock><ticker>ibm</ticker><high>100</high><low>95</low></ticker>
</stock>"/>
</object>

Here is my version of xsl:copy that works for the above case.  Is there
a better solution?
  <xsl:template match="*" mode="xslcopy">
    <<xsl:value-of select="name()"/>
    <xsl:text> </xsl:text>
      <xsl:for-each select="@*">
        <xsl:value-of select="name()"/>='<xsl:value-of select="."/>'
      </xsl:for-each>
      >
      <xsl:if test="count(child::node()) < 2">
        <xsl:value-of select="."/>
      </xsl:if>
      <xsl:apply-templates select="*" mode="xslcopy"/>
    </<xsl:value-of select="name()"/>>
  </xsl:template>

TIA,
Larry Mason

__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now!
http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at
http://webmail.netscape.com/

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


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



<Prev in Thread] Current Thread [Next in Thread>