Subject: Re: [xsl] New user issue: use of Muenchian method From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 21 Sep 2007 11:10:19 -0400 |
Enhancing that xsl to include additional data about subject-areas, I am looking to produce some xml in the following format.
<subject-areas> <subject-area name="System - Team Structure"> <included-table name="team"/> <included-table name="team_level"/ </subject-area> </subject-areas>
I am close to output the above xml apart from the included-table name attribute value.
The source xml that describes subject-areas has included-tables (aka Referenced_Entities) which are listed by giving only their entity reference. For my output xml I need to be look up the entity references in another data structure <Entity> in the source xml. An example of the source xml is shown below:
<Subject_Areas_and_Enities>
<Subject_Area id="{661CB799-677D-4359-A128-46DC5078D9D5}+00000000" name="System - Team Structure"> <Subject_AreaProps> <Name>System - Team Structure</Name> <Referenced_Entities_Array> <Referenced_Entities index="0">{5D393595-7786-46CF-9C35-E68DBD5FC979}+00000000 </Referenced_Entities> <Referenced_Entities index="1">{30882953-C9DF-4911-829E-C1FC00BD8DF8}+00000000</Referenced_En tities> </Referenced_Entities_Array>
<Entity id="{5D393595-7786-46CF-9C35-E68DBD5FC979}+00000000" name="Team"> <EntityProps> <Definition> A Team is a group of workers in an organization. </Definition> <EnityProps> </Entity> </Subject_Areas_and_Enities>
The latest xsl I have developed to solve this issue is as follows:
<?xml version='1.0'?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xpath-default-namespace="http://www.ca.com/erwin/data"> <xsl:output method="xml" indent="yes"/>
<xsl:key name="entity-id" match="Entity_Groups/Entity" use="@id"/>
<xsl:template match="/"> <xsl:apply-templates/>
</xsl:template>
<xsl:template match="Subject_Area_Groups">
<Subject_Areas> <xsl:apply-templates select="Subject_Area"/> </Subject_Areas> </xsl:template>
<xsl:template match="Subject_Area"> <Subject_Area> <xsl:value-of select="@name"/> <xsl:apply-templates select="Subject_AreaProps/Referenced_Entities_Array/Referenced_Entities" /> </Subject_Area> </xsl:template>
<xsl:template match="Subject_AreaProps/Referenced_Entities_Array/Referenced_Entities"> <included-table> <xsl:value-of select="text()"/>
<xsl:for-each select="key('entity-id','@id')"> <xsl:value-of select="EntityProps/Name"/> </xsl:for-each>
</included-table> </xsl:template>
</xsl:stylesheet>
Which outputs the following xml
<Subject_Area>System - Team Structure
<included-table>{5D393595-7786-46CF-9C35-E68DBD5FC979}+00000000</include d-table> <included-table>{30882953-C9DF-4911-829E-C1FC00BD8DF8}+00000000</include d-table> <included-table>{4618F205-F37B-4350-B520-97E25C1DB431}+00000000</include d-table> <included-table>{93B83CDF-8EC0-403B-841B-5A43BDCF9C84}+00000000</include d-table> <included-table>{97A23510-C05B-4851-862B-E4F22D87BBBC}+00000000</include d-table> <included-table>{C530758F-B0E8-438D-85EC-DF32328008C2}+00000000</include d-table> <included-table>{3E248AC3-185F-40F9-85C9-2434D77751AF}+00000000</include d-table> <included-table>{AA077968-89A2-40E5-BCF8-CE75D7C52071}+00000000</include d-table> </Subject_Area>
Followed by a huge amount of output in the following format:
<xsl:template match="/"> <xsl:apply-templates select="path/to/the/element/named/Subject_Area_Groups"> </xsl:template>
So far I have studied http://www.w3schools.com/xsl/el_key.asp and http://www.jenitennison.com/xslt/grouping/muenchian.html and experimented with many variations but seem to have hit an impasse. I would be grateful for any help.
-- Upcoming public training: UBL and code lists Oct 1/5; Madrid Spain 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 Jul'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] New user issue: use of Muenc, Dunk, Michael (Mike) | Thread | Re: [xsl] New user issue: use of M, Wendell Piez |
Re: RES: [xsl] Inserting an XSL var, David Carlisle | Date | Re: [xsl] Apply for-each-group to a, Raman Gupta |
Month |