|
Subject: [xsl] [XSLT-2.0] Template rules matching elements by type From: drkm <darkman_spam@xxxxxxxx> Date: Sun, 30 Oct 2005 16:03:07 +0100 (CET) |
Hi
I'm trying the schema features of XSLT 2.0 and XPath 2.0,
with Altova XML (the only free schema-aware XSLT 2.0
processor I know). But I don't succeed for now to write a
template rule matching elements by type. Here is a minimal
example:
~> cat schema-aware.xsd
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:my="http://www.fgeogres.org/dummy"
targetNamespace="http://www.fgeogres.org/dummy"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<xs:complexType name="list_type">
<xs:sequence>
<xs:element ref="my:elem" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="elem_type">
<xs:restriction base="xs:string">
<xs:enumeration value="val1"/>
<xs:enumeration value="val2"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="list" type="my:list_type"/>
<xs:element name="elem" type="my:elem_type"/>
</xs:schema>
~> cat schema-aware.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://www.fgeogres.org/dummy">
<xsl:output method="text"/>
<xsl:import-schema schema-location="schema-aware.xsd"/>
<xsl:template match="node()">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="element(*,my:list_type)">
<xsl:text>A 'list_type' element: '</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>' </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="element(*,my:elem_type)">
<xsl:text>An 'elem_type' element: '</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>' </xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
~> cat schema-aware.xml
<list xmlns="http://www.fgeogres.org/dummy">
<elem>val1</elem>
<elem>val2</elem>
<elem>val2</elem>
<elem>val1</elem>
</list>
~> altova-xml /xslt2 schema-aware.xsl /in schema-aware.xml
Not really what I did excpect.
Thanks,
--drkm
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Tilichargez cette version sur http://fr.messenger.yahoo.com
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] fold elements in xml tree, bryan rasmussen | Thread | RE: [xsl] [XSLT-2.0] Template rules, Michael Kay |
| [xsl] fold elements in xml tree, Thomas Rasmussen | Date | Re: [xsl] fold elements in xml tree, bryan rasmussen |
| Month |