This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: mixed content styling problem
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: mixed content styling problem
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Thu, 25 May 2000 13:51:57 +0100
- Reply-To: xsl-list at mulberrytech dot com
> I hope someone can assist me with my current situation. I am having
> difficulty styling the emphasis tags within #PCDATA of mixed
> content. I basically need to be able to apply further templates to a
> tree fragment which is not in itself a node.
I can't see why you're making this so complicated, unless there's some
aspect of the problem I've missed completely!
> <!-- Add italics to appropriate areas of the document -->
>
> <xsl:template match="E1">
> <xsl:call-template name="inline.italic"/>
> </xsl:template>
>
> <xsl:template name="inline.italic">
> <xsl:param name="content">
> <xsl:apply-templates/>
> </xsl:param>
> <I><xsl:copy-of select="$content"/></I>
> </xsl:template>
So far that seems equivalent to saying
<xsl:template match="E1">
<I><xsl:apply-templates/></I>
</xsl:template>
>
>
> <!-- Extract and output publish B information -->
>
> <xsl:template match="A">
> <xsl:call-template name="B.output"/>
> </xsl:template>
>
> <xsl:template name="B.output">
> <xsl:for-each select="B">
> <xsl:if test="string(@TYPE)='PUB'">
> <xsl:variable name="BInfo">
> <xsl:copy-of select="child::node()[following::C]"/>
> </xsl:variable>
> <H2><xsl:copy-of select="$BInfo"/></H2>
> <!-- <H2><xsl:apply-templates select="$BInfo"/></H2> -->
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
>
I read your intent as being "copy all B child nodes of the A element
provided they have @TYPE="PUB" and a following C element". You can write
that as
<xsl:template match="A">
<xsl:copy-of select="child::node()[@TYPE='PUB' and following::C]"/>
</xsl:template>
> Result if commented output line is used (from Saxon):
>
> Error while applying stylehsheet
> At xsl:apply-templates on line 172 of file etc...
> Cannot convert value [** RESULT TREE FRAGMENT **] to a node-set
To apply templates to a result tree fragment you have to convert it to a
node-set. That can't be done in standard XSLT. In Saxon you can do it using
the saxon:node-set() extension function. In MSXML3 the conversion is
implicit (which is probably non-compliant).
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list