[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sablotron vs. Libxslt probelm

Subject: Sablotron vs. Libxslt probelm
From: Andrew Borsz <andrew@xxxxxxxxxxxxxxx>
Date: Fri, 5 Aug 2005 18:48:14 -0400
libxslt vs sablotron
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.