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

Re: How do I skip an element?

Subject: Re: How do I skip an element?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 5 May 1999 10:56:31 +0100 (BST)
xsl skip an element

}  XML
}  <data>
}  <row><column1>text1a</column1><column2>text1b</column2><column3>text3a</column3></row>
}  <row><column1>text2a</column1><column2>text2b</column2><column3>text3b</column3></row>
}  </data>
}  
}  I want
}  <table>
}  <tr>
}  <th>column1</th>
}  <th>column3</th>
}  </tr>
}  <tr>
}  <td>text1a</td>
}  <td>text1c</td>
}  </tr>
}  <tr>
}  <td>text2a</td>
}  <td>text2c</td>
}  </tr>
}  </table>

Is that _really_ what you want? where is text1c supposed to come from,
which isn't in the source file?

I suspect that given the input

<data>
<row><column1>text1a</column1><column2>text1b</column2><column3>text1c</column3></row>
<row><column1>text2a</column1><column2>text2b</column2><column3>text2c</column3></row>
</data>

you want to cut out column 2 and fabricate a header row, like so:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<table>
<tr>
<th>column1</th>
<th>column3</th>
</tr>
<tr>
<td>text1a</td>
<td>text1c</td>
</tr>
<tr>
<td>text2a</td>
<td>text2c</td>
</tr>
</table>


In case that is what you meant, it was generated by



<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
  xmlns="http://www.w3.org/TR/REC-html40"
  result-ns="">

<xsl:template match="data">
<table>
<tr>
<xsl:for-each select="row[1]/*[not(position() = 2)]">
<th><xsl:value-of select="qname(.)"/></th>
</xsl:for-each>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>


<xsl:template match="row">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>

<xsl:template match="row/*[position()=2]">
</xsl:template>

<xsl:template match="row/*[not(position() = 2)]">
<td>
<xsl:apply-templates/>
</td>
</xsl:template>


</xsl:stylesheet>


 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.