[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSLT 3.1 that keeps both Saxon EE and HE happy and to
I have quite a few attributes whose values are space delimited tokens. Saxon EE bknowsb they are lists of tokens since the schema does have them a lists so they can be constrained and validated at the XSD level. tokenize(./@someAttribute) works great in HE but bombs in EE with A sequence of more than one item is not allowed as the first argument of fn:tokenize() This feels like it should be obvious and trivial but has been irritating me for a while now. Below is an example instance, schema, and xslt that work fine in HE but not EE. I get why it chokes for EE but not how to make it always work. This is a trivial example my real problems tend to be using this in some ugly schematron test so a more general purpose solution like I guess a function smart enough to know what to do? I tried that a bit but it got dumber and dumber the longer I poked at it. So back to just requirements and hoping one of has the obvious answer. Given the sample xml <?xml version="1.0" encoding="UTF-8"?> <sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Example.xsd"> <stuff country='USA'/> <stuff country='USA GBR'/> <stuff country='GBR CAN'/> </sample> Schema ?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="sample"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="stuff"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="stuff"> <xs:complexType> <xs:attribute name="country" use="required" type="countryListType"/> </xs:complexType> </xs:element> <xs:simpleType name="countryListType"> <xs:restriction> <xs:simpleType> <xs:list itemType="countryType"/> </xs:simpleType> <xs:maxLength value="3"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="countryType"> <xs:restriction base="xs:token"> <xs:enumeration value="USA"/> <xs:enumeration value="GBR"/> <xs:enumeration value="CAN"/> </xs:restriction> </xs:simpleType> </xs:schema> and XSL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" exclude-result-prefixes="xs math xd" version="3.1"> <xsl:output indent="yes"/> <xsl:template match="stuff"> <xsl:copy> <xsl:apply-templates select="@country"/> </xsl:copy> </xsl:template> <xsl:template match="@country"> <xsl:for-each select="tokenize(.)"> <country><xsl:value-of select="current()"/></country> </xsl:for-each> </xsl:template> </xsl:stylesheet> with HE I get <?xml version="1.0" encoding="UTF-8"?> <stuff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <country>USA</country> </stuff> <stuff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <country>USA</country> <country>GBR</country> </stuff> <stuff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <country>GBR</country> <country>CAN</country> </stuff> With EE System ID: /Volumes/DNI_SVN/SaxonHE-EE/example.xsl Severity: fatal Problem ID: XPTY0004 Description: A sequence of more than one item is not allowed as the first argument of fn:tokenize() ("USA", "GBR") Start location: 18:44 URL: http://www.w3.org/TR/xpath20/#ERRXPTY0004
|
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
|