Subject:complex mapping Author:eran berkowitz Date:10 Mar 2005 02:50 AM
HI,
I have a problem which I have a feeling can be solved easely but I guess
I just can't see it.
I want to go from this input -
************
<Hobbies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="output_schema.xsd">
<Hobby Hobby_N="Swimming">
<Person firstName="Erick" lastName="Smith"/> </Hobby> <Hobby
Hobby_N="Biking"> <Person firstName="Elizabeth" lastName="Doe"/>
</Hobby> <Hobby Hobby_N="Painting"> <Person firstName="Marry"
lastName="Smith"/> </Hobby> <Hobby Hobby_N="Swimming"> <Person
firstName="Edward" lastName="Doe"/> </Hobby> </Hobbies>
Subject:complex mapping Author:(Deleted User) Date:11 Mar 2005 10:55 AM
Hi, Eran
As you said, the problem you are trying to solve is much easier to do in XSLT 2 through grouping feature.
Current version of mapper does not have visual grouping support. It won't help much for this particular transformation.
You can use mapper to generate a XSLT skeleton(say you link Hobby to Hobby, mapper will generate a for-each for you),
then you can go to code pane to modify the code for your grouping logic.
Let us know if you need help in writing xslt code to do this grouping.
Subject:complex mapping Author:(Deleted User) Date:14 Mar 2005 03:36 PM
I assume you know how to do grouping in XSLT2 which is straight forward. here is one way to do it in<br>
xslt1. The idea is to use two level of for-each to get the persons with unique @Hobby_N. in the <br>
inner for-each, you can group all those personas with same @Hobby_N together.<br>
<br>
<br>
<?xml version='1.0'?><br>
<xsl:stylesheet version="1.0" xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform">">">http://www.w3.org/1999/XSL/Transform"></a><br>
<br>
<xsl:template match="/"><br>
<Hobbies><br>
<xsl:for-each select="Hobbies/Hobby[not(@Hobby_N = preceding-sibling::Hobby/@Hobby_N)]"><br>
<Hobby name="{@Hobby_N}"><br>
<xsl:for-each select="../*[@Hobby_N = current()/@Hobby_N]"><br>
<xsl:copy-of select="*"/><br>
</xsl:for-each><br>
</Hobby><br>
</xsl:for-each><br>
</Hobbies> <br>
</xsl:template><br>
<br>
</xsl:stylesheet><br>
<br>
<br>