Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: rearranging xmls tructure depending on sub object

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 8/25/2009 6:11:00 PM
erik wrote:
> On 25 Aug, 16:06, Martin Honnen <mahotr...@yahoo.de> wrote:
>> It is a grouping problem that can be solved in XSLT 2.0 with
>> xsl:for-each-group and with XSLT 1.0 using Muenchian grouping.
>> Do you use or want to use XSLT 2.0 or 1.0? 2.0 is available with Saxon 9
>> or with AltovaXML tools or with XML editors like Oxygen or Altova XML
>> Spy or Stylus Studio, XSLT 1.0 is available with Microsoft MSXML 3 and
>> later and with .NET's XslCompiledTransform.
>> Let us know which version you use/want to use.


> As long as I can incorporate it in my wcf service (dotnet 3.5 C#
> project) it doesn't matter. I'm grateful for any solution to this
> problem.

Here is an XSLT 2.0 stylesheet:

<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="ArrayOfWorkShift">
     <Array>
       <xsl:for-each-group select="WorkShift" group-by="Person/Name">
         <Person>
           <xsl:copy-of select="Person/Name"/>
           <xsl:for-each-group select="current-group()" 
group-by="WorkPlace/Id">
             <xsl:sort select="WorkPlace/Id" data-type="number"/>
             <WorkPlace>
               <xsl:copy-of select="WorkPlace/Id"/>
               <xsl:for-each select="current-group()">
                 <WorkShift>
                   <xsl:copy-of select="StartTime, EndTime"/>
                 </WorkShift>
               </xsl:for-each>
             </WorkPlace>
           </xsl:for-each-group>
         </Person>
       </xsl:for-each-group>
     </Array>
   </xsl:template>

</xsl:stylesheet>

To use that within a .NET application you need to install Saxon 9 from 
http://saxon.sourceforge.net/. It has lots of documentation, in addition 
http://www.xmlplease.com/saxonaspnet might be of help for a quick start.


-- 

	Martin Honnen --- MVP XML
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent