|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How do I remove an attribute from a file?
At 2004-05-28 12:24 -0700, Jon Steeves wrote:
I have an xml file that contains a tag called <bit>. <bit> has two attribute: type and status, so it often looks like this: If you want to use XSLT to do this, then use an identity transformation where you prescribe that the status attribute of bit elements adds nothing in the construction of the result tree, while everything else reconstructs itself in the result tree. An example is below. Note, however, you may be incurring a capacity and performance hit by using XSLT for such a simple transform ... you may wish to use a program with a SAX interface instead because of a smaller footprint and faster execution. I hope this helps. ........................... Ken T:\ftemp>type jon.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<bits>
<bit type="a" status="b">bitinfo</bit>
<bit type="b" status="c">bitinfo</bit>
<bit type="d">bitinfo</bit>
<bit status="e">bitinfo</bit>
<bit type="f" status="g">bitinfo</bit>
</bits>
T:\ftemp>type jon.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="bit/@status"/><!--add nothing to the result for these--> <xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> T:\ftemp>saxon jon.xml jon.xsl <?xml version="1.0" encoding="utf-8"?><bits> <bit type="a">bitinfo</bit> <bit type="b">bitinfo</bit> <bit type="d">bitinfo</bit> <bit>bitinfo</bit> <bit type="f">bitinfo</bit> </bits> T:\ftemp>
World-wide on-site corporate, govt. & user group XML/XSL training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
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








