[xsl] Building attributes using another template, context node?

Subject: [xsl] Building attributes using another template, context node?
From: "Manos Batsis" <m.batsis@xxxxxxxx>
Date: Thu, 25 Oct 2001 12:27:51 +0300
Hi folks, 

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: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']">
    <xsl:element name="{tr/td[@class='elemType']/p/text()}"
xml:space="preserve">
      <xsl:apply-templates
select="tr/td[@class='childholder']/div/table"  mode="scrapattrs"/>
      <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()"/>
   </xsl:attribute>
</xsl:template>

Can you point me to modifications needed to build the element and it's
properties?
Thank you very much for your time.

Kindest regards,

Manos

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


Current Thread