Subject: Re: [xsl] No Duplicate Contain() is Allowed? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 17 Dec 2007 22:06:42 -0500 |
For those of you who may know something about SQL or XQuery might be able to help me out.
XML: <bookshelf> <book>XSLT 2.0: From Beginning to Professional <topic>XML</topic> <publisher>Wiley</publisher></book> <book>XML in a Nutshell <publisher>Oreilly</publisher</book> <book>XSLT 2.0: Programmer's Reference <topic>XML</topic> <publisher>Wrox</publisher> </book> </bookshelf>
XSLT:
<xsl:template match="bookshelf"> <xsl:if test="contains(//book/*, 'XML')"> <xsl:apply-templates/> </xsl:if> <xsl:if test="contains(//topic/*, 'XML')"> <xsl:apply-templates/> </xsl:if> </xsl:template>
What happened is really weird. If I had commented out the 2nd <xsl:if> statement, it brings back one line without error.
When I got to the 2nd one, it tells me this error: Description: A sequence of more than one item is not allowed as the first argument of contains() ("", "", ...)
My document is obviously well-formed, can anyone please give me some suggestions on how to get rid of this error?
T:\ftemp>type alice.xml <bookshelf> <book>XSLT 2.0: From Beginning to Professional <topic>XML</topic> <publisher>Wiley</publisher></book> <book>XML in a Nutshell <publisher>Oreilly</publisher></book> <book>XSLT 2.0: Programmer's Reference <topic>XML</topic> <publisher>Wrox</publisher> </book> </bookshelf>
T:\ftemp>type alice.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xsd" version="2.0">
<xsl:template match="bookshelf"> <xsl:if test="contains(//book/*, 'XML')"> <xsl:apply-templates/> </xsl:if> <xsl:if test="contains(//topic/*, 'XML')"> <xsl:apply-templates/> </xsl:if> </xsl:template>
T:\ftemp>type alice2.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xsd" version="2.0">
<xsl:template match="bookshelf"> //book/*: <xsl:value-of select="count(//book/*)"/> //topic/*: <xsl:value-of select="count(//topic/*)"/> </xsl:template>
</xsl:stylesheet> T:\ftemp>call xslt2 alice.xml alice2.xsl alice.out 2>&1
//book/*: 5 //topic/*: 0 T:\ftemp>call xslt2 alice.xml alice3.xsl alice.out 2>&1
T:\ftemp>type alice.out Yes there is a book with a child with 'XML' Yes there is a topic descendant with 'XML'
-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training 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 (F:-0995) Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] No Duplicate Contain() is, Michael Kay | Thread | Re: [xsl] No Duplicate Contain() is, Alice Wei |
Re: [xsl] select first word, Abel Braaksma | Date | [xsl] problem with xsl:if test stat, Amy Huang |
Month |