Subject: Re: [xsl] Using @validation and @type? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 26 Nov 2019 07:50:06 -0000 |
Dear XSL-list,type="xs:integer"
I'm beginning to explore schema-aware processing, and for a real project I need to create some temporary elements with attributes that I would like to treat as integers. In the non-schema-aware version I explicitly pass the attributes through the number() function when I need integer behavior, and that does what I want, but I thought that if I typed the values as xs:integer when creating them they wouldB be recognized as instances of that type when used, and would have integer behavior, so that I could avoidB using the number() function explicitly.
I created a small test sample below that replicates the problem I see in my real code, and I would be grateful if someone could please advise about whatB I've misunderstood. What I think I'm doing is creating a a variable that contains <cell> elements withB @row attributes that are typed as xs:integer, and that therefore should behave as integers when I use them. But when I test in the <xsl:for-each> at the end whether they are instances of integers, the system reports that they are not. I'm running the tests at the command line with Saxon EE and the -sa and -it switches. Thank you for any guidance you might be able to provide.
Best,
David __
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" B B xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="3.0"> B B <xsl:output method="xml" indent="yes"/> B B <xsl:template name="xsl:initial-template"> B B B B <xsl:variable name="test" as="element(test)"> B B B B B B <test xsl:validation="preserve"> B B B B B B B B <xsl:for-each select="1 to 5"> B B B B B B B B B B <cell> B B B B B B B B B B B B <xsl:attribute name="row"
select="."/> B B B B B B B B B B B B <xsl:text>Hi!</xsl:text> B B B B B B B B B B </cell> B B B B B B B B </xsl:for-each> B B B B B B </test> B B B B </xsl:variable> B B B B <xsl:for-each select="$test//cell"> B B B B B B <xsl:message select="@row, @row instance of xs:integer"/> B B B B </xsl:for-each> B B B B <root> B B B B B B <xsl:sequence select="$test"/> B B B B </root> B B </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Using @validation and @type?, David Birnbaum djbpi | Thread | Re: [xsl] Using @validation and @ty, David Birnbaum djbpi |
Re: [xsl] Best practice for typing?, Mukul Gandhi gandhi. | Date | Re: [xsl] Using @validation and @ty, David Birnbaum djbpi |
Month |