Subject: Re: for, was [xsl] max() value of cells in a table From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 17 Apr 2003 09:25:56 +0100 |
Hi Wendell, > Didn't in-stylesheet declarations or type assignments come up once > as a desideratum? I wonder if it got on the list.... There aren't going to be in-stylesheet schema-style declarations, *but* when you create an element or attribute you can assign a type to that element or attribute. If you couple that with the ability to create temporary trees, you've basically got a way of type-annotating a document using XSLT rather than XML Schema. For example, you could do: <!-- The stylesheet has two steps: one that types the tree, the other that processes the typed tree --> <xsl:template match="/"> <xsl:variable name="typed"> <xsl:apply-templates select="*" mode="type" /> </xsl:variable> <xsl:apply-templates select="$typed" /> </xsl:template> <!-- To type the tree, you do an identity transform... --> <xsl:template match="@*|node()" mode="type"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="type" /> </xsl:copy> </xsl:template> <!-- ...with particular templates to type particular nodes: --> <xsl:template match="value" mode="type"> <value xsl:type="xs:integer"> <xsl:value-of select="." /> </value> </xsl:template> <xsl:template match="@date" mode="type"> <xsl:attribute name="date" type="xs:date"> <xsl:value-of select="." /> </xsl:attribute> </xsl:template> This will only work with XSLT processors that support validation, and you can only label an element or attribute with a type if it's one that's built in (i.e. one of the built-in XML Schema types) or if you define it in a schema and then import that schema. > Also (where's Jeni) I think mini-schemas are thinkable; a schema > doesn't have to be comprehensive to assign datatypes (IIRC). I agree that mini-schemas are thinkable. Firstly, a document can be partially valid, so it doesn't matter if a schema doesn't cover the entirety of the document: the typing will apply to those bits of the document that have been validated. Secondly, the way the type matching is designed means that you define substitution groups in a schema and use those substitution groups with a document that hasn't been validated against the schema; I think that could prove quite a neat way of defining ad-hoc collections of elements for particular stylesheets. The other light on the schema-in-XPath horizon is that there's always the potential for schema languages other than XML Schema to be used with XSLT 2.0. There aren't any constraints on what element or attribute declarations, or even type definitions, actually look like, so it should be possible for XSLT processors to use other schema languages. Whether any of them will actually do so is really down to the market... Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: for, was [xsl] max() value of , Wendell Piez | Thread | Re: for, was [xsl] max() value of , David Carlisle |
[xsl] xslt 2.0 examples, David . Pawson | Date | RE: [xsl] Reducing memeory overhead, Jarno . Elovirta |
Month |