RE: [xsl] Problem with xsl:number formatting

Subject: RE: [xsl] Problem with xsl:number formatting
From: "Budinger [US], Bruce" <Bruce.Budinger@xxxxxxxxxxxxxx>
Date: Thu, 9 Aug 2007 10:57:40 -0400
Ken,

Thanks for your response.  I get a different answer when I try your
script.  When I view the file in Internet Explorer I get:

1 CSU Category: Interface
1.1 CSU: Analog Input Interface
1.1.1 SWInterface:
1.2 CSU: Analog Output Interface
1.2.1 SWInterface:
1.3 CSU: Other Interface
1.3.1 SWInterface:
2 CSU Category: Interface
2.1 CSU: Analog Input Interface
2.1.1 SWInterface:
2.2 CSU: Analog Output Interface
2.2.1 SWInterface:
2.3 CSU: Other Interface
2.3.1 SWInterface:
3 CSU Category: Interface
3.1 CSU: Analog Input Interface
3.1.1 SWInterface:
3.2 CSU: Analog Output Interface
3.2.1 SWInterface:
3.3 CSU: Other Interface
3.3.1 SWInterface:
4 CSU Category: Interface
4.1 CSU: Analog Input Interface
4.1.1 SWInterface:
4.2 CSU: Analog Output Interface
4.2.1 SWInterface:
4.3 CSU: Other Interface
4.3.1 SWInterface:

Using your xml and xls file.  Is my problem IE?

Bruce Budinger
Chief Architect - LHD-8
Phone: 434.974.2634
Cell: 434.989-8634

-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, August 08, 2007 6:11 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Problem with xsl:number formatting

At 2007-08-08 17:36 -0400, Budinger [US], Bruce wrote:
>I am trying to create a report from xml data that will appear in an
>appendix. I want to start this report with the letter "E" and have it
>propagate throughout the outline structure.
>
>However, this doesn't seem to be working.  I'm not sure what I am
>missing.

You are missing that value= trumps all other attributes for
<xsl:number/>.

The example below (with expanded input data) illustrates that you need
only specify where to start in the sequence.  You cannot use value= when
trying to reflect the count of nodes in the source node tree.

I hope this helps.

. . . . . . . . . . . Ken

T:\ftemp2>type bruce.xml
<?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet
type="text/xsl" href="test.xsl"?> <root>
   <CSU_Category Name="Interface">
     <CSU Name="Analog Input Interface" >
       <Template Name="C_Module_Template">
       </Template>
     </CSU>
     <CSU Name="Analog Output Interface" >
       <Template Name="F_Module_Template" >
       </Template>
     </CSU>
     <CSU Name="Other Interface" >
       <Template Name="Other_Interface_Template" >
       </Template>
     </CSU>
   </CSU_Category>
   <CSU_Category Name="Interface">
     <CSU Name="Analog Input Interface" >
       <Template Name="C_Module_Template">
       </Template>
     </CSU>
     <CSU Name="Analog Output Interface" >
       <Template Name="F_Module_Template" >
       </Template>
     </CSU>
     <CSU Name="Other Interface" >
       <Template Name="Other_Interface_Template" >
       </Template>
     </CSU>
   </CSU_Category>
   <CSU_Category Name="Interface">
     <CSU Name="Analog Input Interface" >
       <Template Name="C_Module_Template">
       </Template>
     </CSU>
     <CSU Name="Analog Output Interface" >
       <Template Name="F_Module_Template" >
       </Template>
     </CSU>
     <CSU Name="Other Interface" >
       <Template Name="Other_Interface_Template" >
       </Template>
     </CSU>
   </CSU_Category>
   <CSU_Category Name="Interface">
     <CSU Name="Analog Input Interface" >
       <Template Name="C_Module_Template">
       </Template>
     </CSU>
     <CSU Name="Analog Output Interface" >
       <Template Name="F_Module_Template" >
       </Template>
     </CSU>
     <CSU Name="Other Interface" >
       <Template Name="Other_Interface_Template" >
       </Template>
     </CSU>
   </CSU_Category>
</root>

T:\ftemp2>type bruce.xsl
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="CSU_Category">
         <xsl:number format="E" level="multiple"
count="CSU_Category"/> CSU Category: <xsl:value-of select="@Name"/>
         <br/>
         <xsl:apply-templates/>
</xsl:template>

<xsl:template match="CSU">
         <br/>
         <xsl:number level="multiple" format="E.1"
count="CSU_Category|CSU" /> CSU: <xsl:value-of select="@Name"/>
         <br/>
         <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Template">
         <xsl:number level="multiple" format="E.1.1"
count="CSU_Category|CSU|Template"/> SWInterface: <xsl:value-of
select="SWInterface_Name"/>
         <br/>
         <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

T:\ftemp2>call xslt bruce.xml bruce.xsl bruce.out

T:\ftemp2>type bruce.out
<?xml version="1.0" encoding="utf-8"?>
   E CSU Category: Interface<br/>
     <br/>E.1 CSU: Analog Input Interface<br/>
       E.1.1 SWInterface: <br/>


     <br/>E.2 CSU: Analog Output Interface<br/>
       E.2.1 SWInterface: <br/>


     <br/>E.3 CSU: Other Interface<br/>
       E.3.1 SWInterface: <br/>



   F CSU Category: Interface<br/>
     <br/>F.1 CSU: Analog Input Interface<br/>
       F.1.1 SWInterface: <br/>


     <br/>F.2 CSU: Analog Output Interface<br/>
       F.2.1 SWInterface: <br/>


     <br/>F.3 CSU: Other Interface<br/>
       F.3.1 SWInterface: <br/>



   G CSU Category: Interface<br/>
     <br/>G.1 CSU: Analog Input Interface<br/>
       G.1.1 SWInterface: <br/>


     <br/>G.2 CSU: Analog Output Interface<br/>
       G.2.1 SWInterface: <br/>


     <br/>G.3 CSU: Other Interface<br/>
       G.3.1 SWInterface: <br/>



   H CSU Category: Interface<br/>
     <br/>H.1 CSU: Analog Input Interface<br/>
       H.1.1 SWInterface: <br/>


     <br/>H.2 CSU: Analog Output Interface<br/>
       H.2.1 SWInterface: <br/>


     <br/>H.3 CSU: Other Interface<br/>
       H.3.1 SWInterface: <br/>




T:\ftemp2>rem Done!



--
Upcoming public training: XSLT/XSL-FO Sep 10, UBL/code lists Oct 1
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Jul'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread