xsl-list
[Top] [All Lists]

[xsl] New user issue: use of Muenchian method

2007-09-21 07:10:19
Thank you Wendell Piez, Ken Holman and Brad Bjorndahl for your help with
my question the other day.

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:

        
            WQ Team Member
            {0EA17FA0-D21B-4F1E-8B11-A250A6CF266C}+00000000
            
               {A27C38B7-046B-4163-B8AE-BF16138F2CFA}+00000000
               {C43FF91F-5171-46A1-A78C-6073171C4DC0}+00000000
               {615074C8-5BAE-40C0-A743-5A83E85EE993}+00000000
               {F500808A-2A56-4C2E-8BDF-66A8AC39AEF1}+00000000
               {F550391B-0F35-47DC-BFA8-1B83EAC2FA44}+00000000
               {15825A9E-256C-40A2-8AB8-AB7F8CA59B1B}+00000000
               {653AC7D9-078A-4A8B-A3C9-FF7E735AB6F6}+00000000
               {A77FD0CD-A201-49A0-A337-7618B652C1F6}+00000000
               {CE04BDD6-8685-436B-B847-FBCCCD766D0E}+00000000
               {7581671E-FEA1-48D5-8ADA-37680157C72F}+00000000
               {6516EFCA-DC98-4FD6-B450-91B9088E762D}+00000000
               {A06E10C7-C8C1-4426-A590-999D5B56425E}+00000000
            
            
               {C43FF91F-5171-46A1-A78C-6073171C4DC0}+00000000
               {F500808A-2A56-4C2E-8BDF-66A8AC39AEF1}+00000000
               {F550391B-0F35-47DC-BFA8-1B83EAC2FA44}+00000000
               {15825A9E-256C-40A2-8AB8-AB7F8CA59B1B}+00000000
               {653AC7D9-078A-4A8B-A3C9-FF7E735AB6F6}+00000000
               {A77FD0CD-A201-49A0-A337-7618B652C1F6}+00000000
               {CE04BDD6-8685-436B-B847-FBCCCD766D0E}+00000000
               {7581671E-FEA1-48D5-8ADA-37680157C72F}+00000000
               {6516EFCA-DC98-4FD6-B450-91B9088E762D}+00000000
               {A06E10C7-C8C1-4426-A590-999D5B56425E}+00000000
               {A27C38B7-046B-4163-B8AE-BF16138F2CFA}+00000000
               {615074C8-5BAE-40C0-A743-5A83E85EE993}+00000000
            
            
               {A27C38B7-046B-4163-B8AE-BF16138F2CFA}+00000000
               {C43FF91F-5171-46A1-A78C-6073171C4DC0}+00000000
               {615074C8-5BAE-40C0-A743-5A83E85EE993}+00000000
               {F500808A-2A56-4C2E-8BDF-66A8AC39AEF1}+00000000
               {F550391B-0F35-47DC-BFA8-1B83EAC2FA44}+00000000
               {15825A9E-256C-40A2-8AB8-AB7F8CA59B1B}+00000000
               {653AC7D9-078A-4A8B-A3C9-FF7E735AB6F6}+00000000
               {A77FD0CD-A201-49A0-A337-7618B652C1F6}+00000000
               {CE04BDD6-8685-436B-B847-FBCCCD766D0E}+00000000
               {7581671E-FEA1-48D5-8ADA-37680157C72F}+00000000
               {6516EFCA-DC98-4FD6-B450-91B9088E762D}+00000000
               {A06E10C7-C8C1-4426-A590-999D5B56425E}+00000000
            
            
               wqmb
               False
               cases
            




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.
 
Best regards,

Mike

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>