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

Creating then using elements from xml table <row><entr

Subject: Creating then using elements from xml table <row><entry>content?
From: "Kathy Burke" <Kathy_Burke@xxxxxxxxx>
Date: Wed, 29 Oct 2003 13:25:45 -0500
create xml table
Hi. I've not found any references for this and would appreciate some help.
With what I've tried so far, I don't get errors BUT I don't get output
either!

My xml source (created using an xml authoring tool) contains the following:

<tools_materials>
<table><tgroup cols="2">
<?PubTbl tgroup dispwid="6.78in"?>
<colspec colname="col1" colwidth="1.26*"/><colspec colname="col2"
colwidth="0.74*"/>
<tbody><row><entry>Tool/Material</entry>
<entry>Part Number</entry></row>
<row><entry>Operations Manual</entry><entry>092022-001</entry>
</row><row><entry>Machine Management System</entry>
<entry>10-MS30-1000-021</entry></row></tbody></tgroup></table>
</tools_materials>

In my stylesheet, I need to create parent/child elements from the table
content (excluding row 1), ex:

   Column 1 = <tool_mat>Operations Manual
   Column 2 =      <tool_partno>092022-001</tool_partno>
                     </tool_mat>                 

I then need to use those newly created elements in an html table. I have the
following xsl (the first template is just my feeble attempt):

<xsl:template match="tools_materials/table">    <!-- just trying to get the
first element -->
	<xsl:for-each select="row[position() != 1]">
                  <xsl:element name="tool_mat">
		<xsl:value-of
select="normalize-space(cell[1])"/></xsl:element>
	</xsl:for-each>
</xsl:template>
	
<xsl:template match="tools_materials">
     <table border="1" width="100%" cellpadding="4">
	<tr bgcolor="orange" valign="middle">
	    <th colspan="3" align="left">
		<h3>TOOLS AND MATERIALS</h3>
	    </th>
	</tr>
	<tr>
	     <td colspan="2">
	          <b>Tool/Material</b>
	     </td>
	     <td align="center">
		<b>Jabil Part No.</b>
	     </td>
	</tr>
	     <xsl:apply-templates select="tools_materials/table"/>
                 <xsl:apply-templates select="tool_mat"/>
      </table>
</xsl:template>

<xsl:template match="tool_mat">
	<tr>
	     <td align="left" valign="top" width="60%">
		<table border="0">
		<tr>
		     <td align="left" valign="top">
		          <xsl:number level="single" format="1. "
count="tool_mat" />&#160;
		     </td>
		     <td align="left" valign="top">
			<xsl:value-of select="." />
		     </td>
		</tr>
		</table>
	     </td>
	     <td align="left" valign="top" width="40%">
		<xsl:apply-templates select="tool_partno"/>
	     </td>
	</tr>
</xsl:template>

<xsl:template match="tool_partno">
	<xsl:choose>
		<xsl:when test="text()">
			<xsl:value-of select="."/>
		</xsl:when>
	<xsl:otherwise>NA</xsl:otherwise>
	</xsl:choose>
		<xsl:apply-templates select="tool_partno"/>
</xsl:template>



 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.