Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Ordering my HTML output

From: James Fuller <jim.fuller@-------------->
To:
Date: 3/1/2005 12:21:00 PM
Aaron McGrath wrote:



Hi All!



I have looked through the list and don't seem to find anything that 
answers my specific question, but if there is... I apologise!



I have an xml file similar to this:
<abs:body>
  <abs:heading class='100' string='test'>
     <abs:heading class='200' string='tester'></abs:heading>
        <abs:heading class='300' string='sometext'></abs:heading>
        <abs:heading class='300' string='somemoretext'></abs:heading>
     <abs:heading class='200' string='testing'></abs:heading>
  </abs:heading>
</abs:body>

This is the output I would like:



class = 200 string='tester'
class = 200 string='testing'
class = 300 string='sometext'
class = 300 string='somemoretext'




if i understand correctly



taken the following xml (note I assumed the encapsulation...couldnt 
really understand in your email)



<?xml version="1.0" encoding="UTF-8"?>
<abs:body xmlns:abs="http://www.example.org/test">
   <abs:heading class="100" string="test">
       <abs:heading class="200" string="tester">
           <abs:heading class="300" string="sometext"/>
           <abs:heading class="300" string="somemoretext"/>
       </abs:heading>
   </abs:heading>
</abs:body>

with this xsl



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:abs="http://www.example.org/test"
   version="1.0">
   <xsl:template match="abs:body">

       <xsl:apply-templates select="//abs:heading">
           <xsl:sort select="@class"/>
       </xsl:apply-templates>

   </xsl:template>

   <xsl:template match="abs:heading">   
       class = <xsl:value-of select="@class"/> string='<xsl:value-of 
select="@string"/>'      
   </xsl:template>

</xsl:stylesheet>



will give u part of the solution...note the usage of <xsl:sort/>...



if u want to omit something from processing just add a matching template 
which prints out nothing



<xsl:template match="abs:heading[@class='somevalue']"></xsl:template>



note u must supply the somevalue



hth, Jim Fuller


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