[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: mixed content styling problem
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|