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

RE: Building attributes using another template, contex

Subject: RE: Building attributes using another template, context node?
From: Jarno.Elovirta@xxxxxxxxx
Date: Thu, 25 Oct 2001 12:50:04 +0300
html td class attribute
Hip hei!

> I would really appreciate some help on this one :-)
> Suppose I have the following:
> 
> <html:table cellspacing="0" cellpadding="0" xed:nodeType="element"
> xmlns:xed="http://www.foo.org/foo/">

html namespace declaration is missing.

> 	<html:tr>
> 		<html:td class="elemType">
> 			<html:button class="shown"/>
> 			<html:p
> class="elemNameTextArea">xsl:stylesheet</html:p>
> 		</html:td>
> 		<html:td class="childHolder">
> 			<html:div class="hide">
> 				<html:table cellspacing="0"
> cellpadding="0" xed:nodeType="attribute">
> 					<html:tr>
> 						<html:td
> class="attrType">
> 							<html:button
> class="hidden"/>
> 							<html:p
> class="elemAttrTextArea">version</html:p>
> 						</html:td>
> 						<html:td>
> 							<html:p
> class="xedValue" xed:areaType="attrValue">1.0</html:p>
> 						</html:td>
> 					</html:tr>
> 				</html:table>
> 			</html:div>
> 		</html:td>
> 	</html:tr>
> </html:table>
> 
> I have a template that matches the outer table with the
> xed:nodeType="element" attribute-value pair. I use it to output an
> element from the html:p in it's first TD. 
> Now, the problem. I am trying to construct the attribute of that
> element, using the inner table (the one with the
> xed:nodeType="attribute"). My template for the first table is:
> 
> <xsl:template match="table[@xed:nodeType='element']">

The source uses the html namespace, so you have to use non-default namespace
for html in expressions - same goes for all the other expressions below

>     <xsl:element name="{tr/td[@class='elemType']/p/text()}"
> xml:space="preserve">

xml:space here makes the indentation whitespace part of the content of the
element, and you cannot add an attribute node to an element after you've
added non-attribute nodes to it. thus, remove the whitespace before the
xsl:apply-template below

>       <xsl:apply-templates
> select="tr/td[@class='childholder']/div/table"  mode="scrapattrs"/>

In the source the value of the class attribute is childHolder, = does a
case-sensitive comparison on strings.

>       <xsl:apply-templates/>
>    </xsl:element>
> </xsl:template>
> 
> This is a really messed up version of the second template... 
> 
> <xsl:template name="scrapattrs" mode="scrapattrs"
> match="table[@xed:nodeType='attribute']">
>    <xsl:attribute name="{tr/td[@class='attrType']/p/text()}">
> 	<xsl:value-of select="tr/td/p[@areaType='attrValue']/text()"/>

Here add the html namespace prefixes, but areaType attribute is also on
non-null namespace in your source.

>    </xsl:attribute>
> </xsl:template>

Jarno

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


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.