Re: [xsl] Hi ... brand new to list ... and of course .. I need help ... RE xsl:sort

Subject: Re: [xsl] Hi ... brand new to list ... and of course .. I need help ... RE xsl:sort
From: Mukul Gandhi <mukulw3@xxxxxxxxx>
Date: Tue, 22 Jul 2003 21:45:16 -0700 (PDT)
i slighty changed the XSL you have written. i
introduced a <xsl:for-each loop instead of
<xsl:apply-templates and have used <xsl:sort to sort
the records based on <revision> tag. Below is the
complete XSL. i guess you mean Alpha based on
<revision> tag..

Regards,
Mukul


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
  <xsl:param name="title"/>
  <xsl:output method="text"/>
  
  <xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="attribute::*[. != '']"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
	
  <xsl:variable name="newline">
    <xsl:text>
    </xsl:text>
  </xsl:variable>
	
  <xsl:template match="tagdiff">
    <xsl:value-of select="$title"/>
    Differences between <xsl:value-of
select="@startTag"/>
    <xsl:value-of select="@startDate"/> and
<xsl:value-of select="@endTag"/>
    <xsl:value-of select="@endDate"/>
    <xsl:value-of select="$newline"/>
    <xsl:call-template name="show-entries">
    <xsl:with-param name="title">New
Files</xsl:with-param>
    <xsl:with-param name="entries"
select=".//entry[file/revision][not(file/prevrevision)]"/>
    </xsl:call-template>
    <xsl:call-template name="show-entries">
    <xsl:with-param name="title">Modified
Files</xsl:with-param>
    <xsl:with-param name="entries"
select=".//entry[file/revision][file/prevrevision]"/>
  </xsl:call-template>
  <xsl:call-template name="show-entries">
    <xsl:with-param name="title">Removed
Files</xsl:with-param>
    <xsl:with-param name="entries"
select=".//entry[not(file/revision)][not(file/prevrevision)]"/>
  </xsl:call-template>
</xsl:template>
	
<xsl:template name="show-entries">
  <xsl:param name="title"/>
  <xsl:param name="entries"/>
  <xsl:value-of select="$newline"/>
  <xsl:value-of select="$title"/>  -  <xsl:value-of
select="count($entries)"/> Entries
  <xsl:value-of select="$newline"/>
             
  <xsl:for-each select="$entries">
    <xsl:sort select="file/revision" />
    <xsl:value-of select="file/name"/>
    <xsl:value-of select="$newline"/>  
  </xsl:for-each>		      
  <xsl:value-of select="$newline"/>
</xsl:template>
	
</xsl:stylesheet>


--- David TROGDON <David.TROGDON@xxxxxxxxxxxxxxxxx>
wrote:
> My XML file looks like this ... except with a few
> hundred more entry's
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <tagdiff startTag="DEV-030703-00E"
> endTag="DEV-030707-00E">
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/EmailNotification.java</name>
>                   <revision>1.28</revision>
>                   <prevrevision>1.27</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/Finisher.java</name>
>                   <revision>1.26</revision>
>                   <prevrevision>1.25</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
>
<name>na/biomerieux/brns/notification/Sender.java</name>
>                   <revision>1.25</revision>
>                   <prevrevision>1.24</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/TC_EmailErrorNotification.java</name>
>                   <revision>1.5</revision>
>                   <prevrevision>1.4</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/TC_EmailSender.java</name>
>                   <revision>1.4</revision>
>                   <prevrevision>1.3</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/TC_FaxErrorNotification.java</name>
>                   <revision>1.6</revision>
>                   <prevrevision>1.5</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/TC_Finisher.java</name>
>                   <revision>1.29</revision>
>                   <prevrevision>1.28</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
> 
>
<name>na/biomerieux/brns/notification/TC_NotificationEventLogger.java</name>
>                   <revision>1.4</revision>
>                   <prevrevision>1.3</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/Common.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/CompositeLens.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/CompositeSheet.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/Context.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/EmptyPaintable.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/FixedContainer.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> <entry>
>             <file>
>                  
> <name>inetsoft/report/HttpPrinter.java</name>
>                   <revision>1.2</revision>
>                   <prevrevision>1.1</prevrevision>
>             </file>
>       </entry>
> 
> </tagdiff>
> 
> 
> 
> My XSLT style sheet is as follows ..........
> 
> 
> 
> <!-- a stylesheet to display changelogs ala netbeans
> -->
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version
> ="1.0">
>       <xsl:param name="title"/>
>       <xsl:output method="text"/>
>       <xsl:template match="*">
>             <xsl:copy>
>                   <xsl:copy-of
> select="attribute::*[. != '']"/>
>                   <xsl:apply-templates/>
>             </xsl:copy>
>       </xsl:template>
>       <xsl:variable name="newline">
>             <xsl:text>
> </xsl:text>
>       </xsl:variable>
> 
> 
>       <xsl:template match="tagdiff">
>             <xsl:value-of select="$title"/>
>             Differences between <xsl:value-of
> select="@startTag"/>
>             <xsl:value-of select="@startDate"/> and
> <xsl:value-of select="
> @endTag"/>
>             <xsl:value-of select="@endDate"/>
>             <xsl:value-of select="$newline"/>
> 
>             <xsl:call-template name="show-entries">
>                   <xsl:with-param name="title">New
> Files</xsl:with-param>
>                   <xsl:with-param name="entries"
> select
> =".//entry[file/revision][not(file/prevrevision)]"/>
>             </xsl:call-template>
> 
>             <xsl:call-template name="show-entries">
>                   <xsl:with-param
> name="title">Modified
> Files</xsl:with-param>
>                   <xsl:with-param name="entries"
> select
> =".//entry[file/revision][file/prevrevision]"/>
>             </xsl:call-template>
> 
>             <xsl:call-template name="show-entries">
>                   <xsl:with-param
> name="title">Removed
> Files</xsl:with-param>
>                   <xsl:with-param name="entries"
> select
>
=".//entry[not(file/revision)][not(file/prevrevision)]"/>
>             </xsl:call-template>
>       </xsl:template>
> 
>       <xsl:template name="show-entries">
>             <xsl:param name="title"/>
>             <xsl:param name="entries"/>
>             <xsl:value-of select="$newline"/>
>             <xsl:value-of select="$title"/>  - 
> <xsl:value-of select="count
> ($entries)"/> Entries
>                   <xsl:value-of select="$newline"/>
> 
>                   <xsl:apply-templates
> select="$entries"/>
>                   <xsl:value-of select="$newline"/>
> 
>       </xsl:template>
> 
>       <xsl:template match="entry">
>             <xsl:apply-templates select="file"/>
>       </xsl:template>
> 
>       <xsl:template match="file">
>             <xsl:value-of select="name"/>
>             <xsl:if
> test="string-length(prevrevision) > 0 or
> string-length(revision) > 0">
>                   <xsl:text/>
>             </xsl:if>
>             <xsl:if
> test="string-length(prevrevision) = 0 and
> string-length(revision) = 0"/>
>             <xsl:value-of select="$newline"/>
>       </xsl:template>
> 
> 
> 
> </xsl:stylesheet>
> 
> 
> 
> and produces a reasonable output similar to:
> 
> 
>             Differences between DEV-030703-00E and
> DEV-030707-00E
> 
> New Files  -  2 Entries
> 
> .cvsignore
> genericWindows.txt
> 
> 
> Modified Files  -  435 Entries
> 
>
na/biomerieux/brns/notification/EmailNotification.java
> na/biomerieux/brns/notification/Finisher.java
> na/biomerieux/brns/notification/Sender.java
>
na/biomerieux/brns/notification/TC_EmailErrorNotification.java
> na/biomerieux/brns/notification/TC_EmailSender.java
>
na/biomerieux/brns/notification/TC_FaxErrorNotification.java
> na/biomerieux/brns/notification/TC_Finisher.java
>
na/biomerieux/brns/notification/TC_NotificationEventLogger.java
> inetsoft/report/Common.java
> inetsoft/report/CompositeLens.java
> inetsoft/report/CompositeSheet.java
> inetsoft/report/Context.java
> inetsoft/report/EmptyPaintable.java
> inetsoft/report/FixedContainer.java
> inetsoft/report/HttpPrinter.java
> inetsoft/report/PDFPrinter.java
> inetsoft/report/PSPrinter.java
> inetsoft/report/PageArea.java
> inetsoft/report/Painter.java
> inetsoft/report/Presenter.java
> inetsoft/report/PreviewGraphics.java
> inetsoft/report/PreviewPage.java
> inetsoft/report/PreviewPane.java
> inetsoft/report/PreviewView.java
> 
> 
> Removed Files  -  4 Entries
> 
> GenericPropertiesInsideVA.txt
> GenericPropertiesOutsideVA.txt
> README.txt
> generic.txt
> 
> 
> 
> The problem I have is trying to implement the
> xsl:sort command so that each
> section, New Files, Modified Files and Removed Files
> are sorted by Alpha
> .....
> 
> I tried almost every concievable structure I can
> think of ... I eaither
> baffle the parser, fail to sort, or suceed at
> sorting but destroy the
> format.
> 
> 
> If someone has a solution ... I would apprecaite it
> very much.
> 
> Thanks
> 
> David T.
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread