|
Subject: Re: [xsl] De Normalize XML using XSLT From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 14 Oct 2009 16:48:12 -0400 |
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.
t:\ftemp>type s1.xml <consignment> <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> <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/> </consignment>
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: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>-- 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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] De Normalize XML using XSLT, Senthilukvelaan | Thread | Re: [xsl] De Normalize XML using XS, Senthilukvelaan |
| Re: [xsl] Change xml:lang of a skos, G. Ken Holman | Date | Re: [xsl] Change xml:lang of a skos, Jürgen Jakobitsch |
| Month |