Subject: Re: [xsl] Using @validation and @type? From: "David Birnbaum djbpitt@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 26 Nov 2019 08:10:00 -0000 |
I donbt import a schema, and, for that matter, I donbt transform a document. I create temporary elements inside the stylesheet and I want some of their attributes to be typed as integers. Ibm not trying to validate anything except the typing on these ephemeral elements. > On Nov 25, 2019, at 11:50 PM, Martin Honnen martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > o;?Am 26.11.2019 um 02:38 schrieb David Birnbaum djbpitt@xxxxxxxxx: >> Dear XSL-list, >> >> 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 would be >> recognized as instances of that type when used, and would have integer >> behavior, so that I could avoid 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 what I've misunderstood. What I think I'm doing is >> creating a a variable that contains <cell> elements with @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" >> xmlns:xs="http://www.w3.org/2001/XMLSchema" >> exclude-result-prefixes="xs" version="3.0"> >> <xsl:output method="xml" indent="yes"/> >> <xsl:template name="xsl:initial-template"> >> <xsl:variable name="test" as="element(test)"> >> <test xsl:validation="preserve"> >> <xsl:for-each select="1 to 5"> >> <cell> >> <xsl:attribute name="row" type="xs:integer" >> select="."/> >> <xsl:text>Hi!</xsl:text> >> </cell> >> </xsl:for-each> >> </test> >> </xsl:variable> >> <xsl:for-each select="$test//cell"> >> <xsl:message select="@row, @row instance of xs:integer"/> >> </xsl:for-each> >> <root> >> <xsl:sequence select="$test"/> >> </root> >> </xsl:template> >> </xsl:stylesheet> > > > Where do you import a schema?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using @validation and @ty, Martin Honnen martin | Thread | Re: [xsl] Using @validation and @ty, Michael Kay mike@xxx |
Re: [xsl] Using @validation and @ty, Martin Honnen martin | Date | Re: [xsl] Using @validation and @ty, Michael Kay mike@xxx |
Month |