View Single Post
  #5 (permalink)  
Old January 18th, 2011, 09:31 AM
acctoujours acctoujours is offline
Registered User
 
Join Date: Jan 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okk, my input.xml and stylesheet are:

input.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<enfinity
xmlns="http://www.intershop.com/xml/ns/enfinity/6.5/bc_pmc/impex"
xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/6.5/bc_pmc/impex bc_pmc.xsd">
<pagelet-page id="pg_20100829_210957">
<definition-name>pagevariation.productComparision.pagelet2-pagevariation.productComparision</definition-name>
<display-name xml:lang="en-US">Default Product Comparision</display-name>
<description xml:lang="en-US"></description>
<valid-from>08/29/10 09:09:00 pm</valid-from>
<online>true</online>
<author business-partner-no="admin" domain="LeviStrauss"/>
<configuration-parameters>
<configuration-parameter name="metaInfo">
<definition-name>pagevariation.productComparision.pagelet2-pagevariation.productComparision-metaInfo</definition-name>
</configuration-parameter>
</configuration-parameters>
<slots>
<slot>
<definition-name>slots.main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
<slot>
<definition-name>aslots.main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
</slots>
<custom-attributes>
</custom-attributes>
</pagelet-page>
<pagelet-page id="pg_20100811_162140">
<definition-name>pagevariation.homepage.pagelet2-pagevariation.homepage</definition-name>
<display-name xml:lang="en-US">Default Homepage</display-name>
<valid-from>08/11/10 04:21:00 pm</valid-from>
<online>true</online>
<author business-partner-no="admin" domain="LeviStrauss"/>
<configuration-parameters>
<configuration-parameter name="metaInfo">
<definition-name>pagevariation.homepage.pagelet2-pagevariation.homepage-metaInfo</definition-name>
</configuration-parameter>
</configuration-parameters>
<slots>
<slot>
<definition-name>slots.main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
<slot>
<definition-name>main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
</slots>
<custom-attributes>
</custom-attributes>
</pagelet-page>
</enfinity>
xsl
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:impex="http://www.x.com/xml/ns/xXx/6.5/bc_pmc/impex"
  version="1.0">
  
  <xsl:strip-space elements="*"/>
  <xsl:output indent="yes"/>
  
  <xsl:template match="@* | text() | comment() | processing-instruction()">
    <xsl:copy/>
  </xsl:template>
  
  <xsl:template match="*[*]">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="*">
        <xsl:sort select="local-name()" data-type="text"/>
        <xsl:sort select="@id" data-type="text"/>
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="*[not(*)]">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="impex:pagelet-page/impex:slots" priority="5">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="impex:slot">
        <xsl:sort select="impex:definition-name"/>
      </xsl:apply-templates>
    </xsl:copy>
  </xsl:template>  

</xsl:stylesheet>
The result is a sorted XML file, but slot tags are not sorted by its definition-name inside each slots tag.

I need the following result:
Code:
<?xml version="1.0" encoding="UTF-16"?>
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/6.5/bc_pmc/impex bc_pmc.xsd" xmlns="http://www.intershop.com/xml/ns/enfinity/6.5/bc_pmc/impex" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pagelet-page id="pg_20100811_162140">
<author business-partner-no="admin" domain="LeviStrauss">
</author>
<configuration-parameters>
<configuration-parameter name="metaInfo">
<definition-name>pagevariation.homepage.pagelet2-pagevariation.homepage-metaInfo</definition-name>
</configuration-parameter>
</configuration-parameters>
<custom-attributes>
</custom-attributes>
<definition-name>pagevariation.homepage.pagelet2-pagevariation.homepage</definition-name>
<display-name xml:lang="en-US">Default Homepage</display-name>
<online>true</online>
<slots>
<slot>
<definition-name>main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
<slot>
<definition-name>slots.main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
</slots>
<valid-from>08/11/10 04:21:00 pm</valid-from>
</pagelet-page>
<pagelet-page id="pg_20100829_210957">
<author business-partner-no="admin" domain="LeviStrauss">
</author>
<configuration-parameters>
<configuration-parameter name="metaInfo">
<definition-name>pagevariation.productComparision.pagelet2-pagevariation.productComparision-metaInfo</definition-name>
</configuration-parameter>
</configuration-parameters>
<custom-attributes>
</custom-attributes>
<definition-name>pagevariation.productComparision.pagelet2-pagevariation.productComparision</definition-name>
<description xml:lang="en-US">
</description>
<display-name xml:lang="en-US">Default Product Comparision</display-name>
<online>true</online>
<slots>
<slot>
<definition-name>aslots.main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
<slot>
<definition-name>slots.main.pagelet2-slotContent</definition-name>
<optional>false</optional>
<sorting>false</sorting>
</slot>
</slots>
<valid-from>08/29/10 09:09:00 pm</valid-from>
</pagelet-page>
</enfinity>
Thanks!!,
Juan V.
Reply With Quote