[Home] [By Thread] [By Date] [Recent Entries]
At 2009-10-14 13:31 -0700, Senthilukvelaan wrote:
I would like to know is there any way to group the nodes of the xml using the node name matching pattern starts-with like the sample provided. By using the starts-with() function in a predicate. But since you've said "starts with" then I'm assuming you know in advance what all of the substitutions are. I hope the example below helps ... but I suspect you haven't described your requirement precisely. . . . . . . . . Ken
t:\ftemp>call xslt s1.xml s.xsl s1.out t:\ftemp>type s1.out
<?xml version="1.0" encoding="utf-8"?>
<consignment>
<SHIPMENT>
<SHIP_NAME1>Suresh</SHIP_NAME1>
<SHIP_NAME3/>
<SHIP_NAME4/>
<SHIP_COLONIA/>
<SHIP_CITY> Newyork </SHIP_CITY>
<SHIP_POST_CODE>L3R 1A3</SHIP_POST_CODE>
<SHIP_STREET>1010 Woodbine Ave</SHIP_STREET>
<SHIP_COUNTRY>CA</SHIP_COUNTRY>
<SHIP_COUNTRY_NAME>Canada</SHIP_COUNTRY_NAME>
<SHIP_REGION>ON</SHIP_REGION>
<SHIP_REGION_DESC>Ontario</SHIP_REGION_DESC>
</SHIPMENT>
<BILLING>
<BILL_NAME1>Suresh</BILL_NAME1>
<BILL_NAME2/>
<BILL_NAME3/>
<BILL_NAME4/>
<BILL_STREET>7225 woodbine street</BILL_STREET>
<BILL_COLONIA/>
<BILL_CITY>Newyork</BILL_CITY>
<BILL_REGION>ON</BILL_REGION>
<BILL_REGION_DESC>Ontario</BILL_REGION_DESC>
<BILL_COUNTRY>CA</BILL_COUNTRY>
<BILL_COUNTRY_NAME>Canada</BILL_COUNTRY_NAME>
<BILL_POST_CODE>L3R 1A3</BILL_POST_CODE>
<BILL_TELF1>12345</BILL_TELF1>
<BILL_TELF2EXTN/>
</BILLING>
</consignment>
t:\ftemp>type s.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:output indent="yes"/> <xsl:template match="consignment">
<consignment>
<SHIPMENT>
<xsl:copy-of select="*[starts-with(local-name(.),'SHIP_')]"/>
</SHIPMENT>
<BILLING>
<xsl:copy-of select="*[starts-with(local-name(.),'BILL_')]"/>
</BILLING>
</consignment>
</xsl:template></xsl:stylesheet> t:\ftemp>rem Done! -- Upcoming: hands-on code list, UBL, XSLT, XQuery and XSL-FO classes in Copenhagen Denmark and Washington DC USA, October/November 2009 Interested in other classes? http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



