|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Possible to use attribute value in pattern ??
[Lionel Villard]
> I want to select an element from the value of an attribute. For
> instance, consider this small smil document :
I think the id() function should do what you're after. From the XML
doc
<?xml version="1.0" ?>
<!DOCTYPE smil [
<!ATTLIST region id ID #REQUIRED>
<!ATTLIST img id ID #REQUIRED>
]>
<smil>
<head>
<region id="toto" left="10" right="40"/>
</head>
<body>
<img id="MyImg" region="toto"/>
</body>
</smil>
and the stylesheet
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
result-ns="">
<xsl:template match="img[id('MyImg')]">
<xsl:element name="picture">
<xsl:attribute name="name">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:attribute name="left">
<xsl:value-of select="id(@region)/@left"/>
</xsl:attribute>
<xsl:attribute name="right">
<xsl:value-of select="id(@region)/@right"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
XT produces
<picture name="MyImg" left="10" right="40"/>
Pete Johnston
University of Glasgow
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








