[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[XSLT-2.0] Template rules matching elements by type

Subject: [XSLT-2.0] Template rules matching elements by type
From: drkm <darkman_spam@xxxxxxxx>
Date: Sun, 30 Oct 2005 16:03:07 +0100 (CET)
xsl 2.0 template
  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>'&#10;</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>'&#10;</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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.