[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: how to display XML nodes having HTML tags (correction)


Subject: Re: how to display XML nodes having HTML tags (correction)
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Jun 1999 21:35:16 -0400

At 99/06/10 20:49 -0400, I wrote:
>  <xsl:copy select=".">

This is incorrect syntax, as there is no select= attribute on <xsl:copy>
... it copies the current node only.  The corrected "hari2.xsl" is below.

BTW, IE5 does not support the new <xsl:copy-of> construct, so I've shown an
example below using only <xsl:copy> in the file "hari2.msxsl".

Sorry for having shown the construct incorrectly.

........ Ken


T:\hari>type hari2.xml
<?xml version="1.0"?>
<test>
<XMLNode>Hello<b>XSL <XMLNode>abc</XMLNode> List</b></XMLNode>
<XMLNode>Another <img src="http://site/file"/> Test</XMLNode>
</test>
T:\hari>type hari2.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">

<xsl:template match="XMLNode">  <!--make a normal paragraph-->
  <p><xsl:apply-templates/></p>
</xsl:template>

                                <!--list all HTML element types here-->
<xsl:template match="b|img|pre|samp|
                     p|h1|h2|h3">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

T:\hari>call xsl hari2.xml hari2.xsl hari.htm
T:\hari>type hari.htm

<p>Hello<b>XSL <p>abc</p> List</b></p>
<p>Another <img src="http://site/file"/> Test</p>

T:\hari>type hari2.msxsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<!-- default behaviour - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template><xsl:apply-templates/></xsl:template>
<xsl:template match="text()"><xsl:value-of/></xsl:template>

<!-- selective behaviour - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template match="XMLNode">  <!--make a normal paragraph-->
  <p><xsl:apply-templates/></p>
</xsl:template>

                                <!--list all HTML element types here-->
<xsl:template match="b|img|pre|samp|
                     p|h1|h2|h3">
  <xsl:copy>
    <xsl:for-each select="@*">
      <xsl:copy><xsl:value-of select="."/></xsl:copy>
    </xsl:for-each>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

T:\hari>call msxsl hari2.xml hari2.msxsl hari-ms.htm
T:\hari>type hari-ms.htm
<p>Hello<b>
XSL <p>abc</p>
 List</b>
</p>
<p>Another <img src="http://site/file">
</img>
 Test</p>


T:\hari>

--
G. Ken Holman                  mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.           http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0  +1(613)489-0999  (Fax:-0995)
Website: XSL/XML/DSSSL/SGML services outline,  XSL/DSSSL shareware,
         stylesheet resource library, conference training schedule,
         commercial stylesheet training materials, on-line XSL CBT.


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



Current Thread
Keywords
xsl