xsl-list
[Top] [All Lists]

Sablotron vs. Libxslt probelm

2005-08-05 15:48:14
Hello list,
I'm using XSLT 1.0 and I'm running into problems with a difference between Sablotron and Libxslt. I must use Libxslt for my project, but I'm having trouble getting the result I want. I've never had any problems with Libxslt before, but I've heard it's more 'strict'.

In the following example, Sablotron gives me the result I want. Libxslt gives me some duplicate output I don't want.

XML:

<root>
<component>
<unitMeta>
<unitTitle>unit title 1</unitTitle>
<unitSubtitle>unit sub title 1</unitSubtitle>
</unitMeta>
</component>
<component>
<unitMeta>
<unitTitle>unit title 2</unitTitle>
<unitSubtitle>unit sub title 2</unitSubtitle>
</unitMeta>
</component>
</root>

XSL:

<?xml version='1.0'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method='xml' version='1.0'/>

<xsl:template match="root">
<document>
<xsl:apply-templates select="descendant::unitTitle[1]" mode="add"/>
<xsl:apply-templates select="descendant::unitSubtitle[1]" mode="add"/>
<xsl:apply-templates/>
</document>
</xsl:template>

<xsl:template match="component">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="unitMeta">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="unitSubtitle">
<subtitle><b><xsl:apply-templates/></b></subtitle>
</xsl:template>
<xsl:template match="root/component[1]//unitSubtitle[1]">
<!--do not process-->
</xsl:template>
<xsl:template match="root/component[1]//unitSubtitle[1]" mode="add">
<subtitle><b><xsl:apply-templates/></b></subtitle>
</xsl:template>

<xsl:template match="unitTitle">
<title><b><xsl:apply-templates/></b></title>
</xsl:template>
<xsl:template match="root/component[1]//unitTitle[1]">
<!--do not process-->
</xsl:template>
<xsl:template match="root/component[1]//unitTitle[1]" mode="add">
<title><b><xsl:apply-templates/></b></title>
</xsl:template>

</xsl:stylesheet>

There's extra output with Libxslt:

<title><b>unit title 1</b></title>
<subtitle><b>unit sub title 1</b></subtitle>

This appears twice. With Sablotron it appears only once, when called by the moded template. I have to use Libxslt. Please help.

Thanks,

Andrew Borsz


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>
  • Sablotron vs. Libxslt probelm, Andrew Borsz <=