Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: XSLT 2.0 space separated list type access with Saxon 9.1 -sa -val [Thread Next] Re: XSLT 2.0 space separated list type access with Saxon 9.1 -sa -valTo: NULL Date: 2/6/2009 2:33:00 PM RolfK wrote: > It is still not clear to me why e.g. $vAgenda/@CSSColorNames[position() > =2] does not lead to the same result !? I have not much experience with schema-aware XSLT but the problem I think is to distinguish between selecting the second node in a step and the second item in the typed value of a node. Your expression selects the second attribute CSSColorNames. That does not make any sense for attributes as there can't be two attributes of the same type but imagine you had a 'foo' parent element and 'bar' child elements and then you do e.g. foo/bar[position() = 2] or foo/bar[2] that would select the second 'bar' child. If you wanted the typed value of the second 'bar' child then you need data(foo/bar[2]) to distinguish from the earlier expression. Then on the typed value, assuming it is a sequence stemming from a list type, you could apply a predicate again: data(foo/bar[2])[2] > Regarding the type I tried to declare the type bt the "as" attribute. > But this does not work. I have defined the complex type in my schema > as shown. > But how to use it in xslt? > Do I have to import the schema ? > > <xsl:stylesheet version="2.0" xmlns:mgt="MarginTable" ...... > <xsl:import-schema namespace="MarginTable" schema-location="../_xsd/ > MarginTable.xsd"/> > <xsl:template match="/"> > <xsl:variable name="vColorNames" select="$vAgenda/@CSSColorNames" > as="mgt:tCSSColorNames"/> > .... > > Saxon shows this error: > XPST0051: SequenceType syntax error at char 0 in {mgt:tCSSColorNames}: > Type (mgt:tCSSColorNames) is a list or union type > > How to declare it correctly ? The as attribute takes a sequence type, not a schema type. So you would need as="xs:string+" I think. -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
