Subject: Re: [xsl] xml to xml issue in XSLT2.0 From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 19 Nov 2007 14:20:44 -0500 |
Hi Ken Thanks for the help, But yours is : ... While the one that I am looking for is something like
T:\ftemp>type chun.xml <?xml version="1.0" encoding="UTF-8"?> <perm_testing> <user name="SFO"> <tab name="YourSource"> <sub name="Client"> <checkpoint name="View" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="View" value="yes"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="Create" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="Edit" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="Discussion"> <checkpoint name="View" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="Discussion"> <checkpoint name="Create" value="yes"/> </sub> </tab> <tab name="Requisition"> <sub name="Discussion"> <checkpoint name="Edit" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="Resume/Quote"> <checkpoint name="View" value="no"/> </sub> </tab> </user> <user name="ABC"> <tab name="YourSource"> <sub name="Client"> <checkpoint name="View" value="yes"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="View" value="yes"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="Create" value="no"/> </sub> </tab> </user> </perm_testing>
T:\ftemp>type chun.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/> <xsl:strip-space elements="*"/>
<xsl:template match="user"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:for-each-group select="tab/sub" group-by="concat(../@name,'
',@name)"> <tab name="{../@name}"> <sub name="{@name}"> <xsl:apply-templates select="current-group()/checkpoint"/> </sub> </tab> </xsl:for-each-group> </xsl:copy> </xsl:template>
<xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
</xsl:stylesheet> T:\ftemp>call xslt2 chun.xml chun.xsl chun.out
T:\ftemp>type chun.out <?xml version="1.0" encoding="UTF-8"?> <perm_testing> <user name="SFO"> <tab name="YourSource"> <sub name="Client"> <checkpoint name="View" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="View" value="yes"/> <checkpoint name="Create" value="no"/> <checkpoint name="Edit" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="Discussion"> <checkpoint name="View" value="no"/> <checkpoint name="Create" value="yes"/> <checkpoint name="Edit" value="no"/> </sub> </tab> <tab name="Requisition"> <sub name="Resume/Quote"> <checkpoint name="View" value="no"/> </sub> </tab> </user> <user name="ABC"> <tab name="YourSource"> <sub name="Client"> <checkpoint name="View" value="yes"/> </sub> </tab> <tab name="Requisition"> <sub name="General Info"> <checkpoint name="View" value="yes"/> <checkpoint name="Create" value="no"/> </sub> </tab> </user> </perm_testing> T:\ftemp>rem Done!
-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and 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 Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xml to xml issue in XSLT2, chun ji | Thread | Re: [xsl] xml to xml issue in XSLT2, chun ji |
Re: [xsl] xml to xml issue in XSLT2, chun ji | Date | Re: [xsl] xml to xml issue in XSLT2, chun ji |
Month |