Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XSLT 2.0 space separated list type access with Saxon 9.1 -sa -val

From: Martin Honnen <mahotrash@-----.-->
To: 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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent