xsl-list
[Top] [All Lists]

Re: [xsl] Matching elements based on element type:

2006-07-17 09:23:24
Is XSLT2.0 fully supported by any products (any free software products?)?
It feels kind of risky to use a standard that hasn't even been
finalized by the w3c yet...

Regards,
David


2006/7/17, Michael Kay <mike(_at_)saxonica(_dot_)com>:

You write

<xsl:template match="element(*, my_type)">

and use a schema-aware XSLT 2.0 processor.

Michael Kay
http://www.saxonica.com/



> -----Original Message-----
> From: David B [mailto:daavidb(_at_)gmail(_dot_)com]
> Sent: 17 July 2006 16:57
> To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
> Subject: [xsl] Matching elements based on element type:
>
> Hello,
>
> I have an xml file that looks like this:
>
> <top>
>     <a>123</a>
>     <b>456</b>
>     <c>789</c>
> </top>
>
>
> And has a schema as follows:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>     <xs:element name="top">
>         <xs:complexType>
>             <xs:sequence>
>                 <xs:element name="a" type="my_type"/>
>                 <xs:element name="b" type="my_type"/>
>                 <xs:element name="c" type="my_type"/>
>             </xs:sequence>
>         </xs:complexType>
>     </xs:element>
>     <xs:simpleType name="my_type">
>         <xs:restriction base="xs:string"/>
>     </xs:simpleType>
> </xs:schema>
>
> That is, the elements a,b,c all have the type my_type but
> have different element names.
>
> I want an xslt stylesheet that has a single template for all
> elements of type my_type. Something like:
> <xsl:template match="top">
>     <xsl:apply-templates/>
> </xsl:template>
>
> <xsl:template match="*[type()=my_type]">
>      <xsl:value-of select="."/>
> </xsl:template>
>
> Only there is no type() function in XPath....
>
> Is there any other way I could do this?
>
> Best Regards,
> David Belius
>
> --~------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
> --~--
>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--