|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: No Duplicate Contain() is Allowed?
At 2007-12-16 22:37 -0500, Alice Wei wrote:
For those of you who may know something about SQL or XQuery might be able to help me out. The issue is not related to either of those.
This does not happen for me ... I get the same error as you quote below on the first xsl:if regardless of whether or not the second xsl:if is present. And given what I see, I expect you to get the error on both. I show my transcript below. And I created another stylesheet "alice2.xsl" that counts the nodes you've addressed. 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() ("", "", ...) The first argument to contains() must be a single item (element, string, attribute, whatever), and the function acts on the string value of that item. If you supply more than one item, that is an error. And, indeed, in both cases you are supplying more than one item. My document is obviously well-formed, can anyone please give me some suggestions on how to get rid of this error? Your address does not look like what I think you want. You have "//book/*" ... which finds all children addressed by all books in the entire instance. I see three elements named "book", the first has two child elements, the second has one, and the third has two, for a total of 5. So, you are passing five strings to the contains() instruction, so you are getting the error. I think you might want what is in the third stylesheet "alice3.xsl" if you want to test that *any* of the addressed elements have 'XML' in their values. This uses: test="book/*[contains(.,'XML')]" and test=".//topic[contains(.,'XML')]" I hope this helps. . . . . . . . . . . . Ken
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:output method="text"/> <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></xsl:stylesheet> T:\ftemp>call xslt2 alice.xml alice.xsl alice.out 2>&1 Error on line 10 of file:/T:/ftemp/alice.xsl: XPTY0004: A sequence of more than one item is not allowed as the first argument of contains() ("XML", "Wiley", ...) Transformation failed: Run-time errors were reported 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:output method="text"/> <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 T:\ftemp>type alice.out //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' T:\ftemp>rem Done!
|
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
|

Cart








