|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Filtering, xslt 2.0
Am 11/1/2022 um 9:44 AM schrieb Dave Pawson dave.pawson@xxxxxxxxx:
I suspect it is a shell issue (Using Bash on Linux)
Test case
<?xml version="1.0" encoding="utf-8"?>
<set>
<data>
<name>A</name>
<type>dog</type>
</data>
<data>
<name>B</name>
<type>cat</type>
</data>
<data>
<name>C</name>
<type>mouse</type>
</data>
</set>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:d="http://www.dpawson.co.uk/ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
<xsl:param name="types" as="xs:string"/>
If you declare the type as a single string item, then it doesn't make
sense to attempt to use the "?param-name" syntax further below to pass
in an XPath expression evaluating to a sequence of strings.
So either
B as="xs:string*"
and then
B ?types="('A','B')"
or
B as="xs:string"
and
B types=A,B
and
B test="type = tokenize($types, ',')"
<xsl:strip-space elements="*"/>
<xsl:template match="set">
<xsl:message>
<xsl:value-of select='$types'/>
</xsl:message>
<xsl:for-each select="data">
<xsl:sort select="name"/>
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
<xsl:template match="data">
<xsl:if test="type = $types">
<xsl:apply-templates mode="pass"/>
</xsl:if>
<xsl:if test="contains(concat(',', $types, ','), concat(',', type,
','))">
<xsl:message>
<xsl:value-of select="'Dimitre'"/>
</xsl:message>
</xsl:if>
</xsl:template>
<xsl:template match="name|type" />
<xsl:template match="name|type" mode="pass">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:message>
*****<xsl:value-of select="name(..)"/>/{<xsl:value-of
select="namespace-uri()"/>}<xsl:value-of select="name()"/>******
</xsl:message>
</xsl:template>
</xsl:stylesheet>
1. sax2 seq.xml seq.xsl op.xml ?types='("A", "B")'
Errors with Unrecognized option: "B")
2. sax2 seq.xml seq.xsl op.xml ?types="('A','B')"
XPTY0004: A sequence of more than one item is not allowed as the value
of variable $types
("A", "B")
Saxon version PE 9.6.0.1
Suggestions to get the data into the stylesheet please? An external xml
file?
TiA
regards

|
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
| RSS 2.0 |
|
| Atom 0.3 |
|
|