RE: [xsl] Function id() does not work XSLT - XML - XML-Schema

Subject: RE: [xsl] Function id() does not work XSLT - XML - XML-Schema
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 20 Dec 2002 12:20:56 -0000
XSLT 1.0 isn't defined to work with XML Schema. An implementation could
mark the ID attributes as such, but there is no particular reason why it
should.

If you can't define them as IDs in a DTD, the best thing is probably to
use xsl:key to find them.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> robhan@xxxxxx
> Sent: 20 December 2002 07:19
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Function id() does not work XSLT - XML - XML-Schema
> 
> 
> Hello,
>   
>  Question: Why does the Function id() not work??
>   
>  Explanation: Each Fact has references to Dimension. I'd like 
> to loop  through  all Fact and want to use refDim to get the 
> corresponding Dimension or  Dimension's. Attribute refDim is 
> of type "IDREFS". Attribute id of  Dimension  is of type "ID"
>   
>  For me it looks like, that the xsl transformation does not 
> know the  schema.  Correct? If yes, why?  I have 3 parts 
> which have to work together: XSD - XML - XSLT.  Is somewhere 
> a full example(not cutout's) for these 3 files which uses the 
>  id function?? 
>   
>  wkr
>  robert
>  ----- XSLT -----
>   
>  <?xml version="1.0" encoding="UTF-8"?>
>  <xsl:stylesheet version="1.0"  
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>         <xsl:template match="/">
>               ABC
>               <xsl:value-of select="id('ID000000')"/>
>               <xsl:for-each select="//Dimension">
>                      AAA            
>                      <xsl:value-of select="id('ID000000')"/>
>                      AAA
>                      <xsl:value-of select="."/>
>               </xsl:for-each>
>               DEF
>         </xsl:template>
>  </xsl:stylesheet>
>   
>   
>  ---- XML -----
>  <?xml version="1.0" encoding="UTF-8"?>
>  <?xml-stylesheet type="text/xsl" href="SpeedTest.xslt"?>  
> <SpeedTest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xsi:noNamespaceSchemaLocation="file:///....../SpeedTest.xsd">
>         <Dimensions>
>               <Dimension id="ID000000">
>                      <DimensionValue>D0</DimensionValue>
>               </Dimension>
>         </Dimensions>
>         <Facts>
>               <Fact refDim="ID000000 ID000001">
>                      <Value>FactValue0</Value>
>               </Fact>
>         </Facts>
>  </SpeedTest>
>  ---- XSD ----
>  <?xml version="1.0" encoding="UTF-8"?>
>  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>  elementFormDefault="qualified" attributeFormDefault="unqualified">
>         <xs:element name="SpeedTest">
>               <xs:complexType>
>                      <xs:sequence>
>                             <xs:element name="Dimensions">
>                                   <xs:complexType>
>                                          <xs:sequence>
>                                                 <xs:element  
> name="Dimension"  maxOccurs="unbounded">
>                                                       <xs:complexType>
>                                                              
> <xs:sequence>
>   
>  <xs:element name="DimensionValue">
>   
>  <xs:complexType>
>   
>  <xs:simpleContent>
>   
>  <xs:extension base="xs:string"/>
>   
>  </xs:simpleContent>
>   
>  </xs:complexType>
>   
>  </xs:element>
>                                                              
> </xs:sequence>
>                                                              
> <xs:attribute  name="id" type="xs:ID" use="required"/>
>                                                       
> </xs:complexType>
>                                                 </xs:element>
>                                          </xs:sequence>
>                                   </xs:complexType>
>                             </xs:element>
>                             <xs:element name="Facts">
>                                   <xs:complexType>
>                                          <xs:sequence>
>                                                 <xs:element 
> name="Fact"  maxOccurs="unbounded">
>                                                       <xs:complexType>
>                                                              
> <xs:sequence>
>   
>  <xs:element name="Value" type="xs:string"/>
>                                                              
> </xs:sequence>
>                                                              
> <xs:attribute  name="refDim" type="xs:IDREFS" use="required"/>
>                                                       
> </xs:complexType>
>                                                 </xs:element>
>                                          </xs:sequence>
>                                   </xs:complexType>
>                             </xs:element>
>                      </xs:sequence>
>               </xs:complexType>
>         </xs:element>
>  </xs:schema>
> 
> -- 
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread