[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem with xsl:number formatting

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

Thanks for your help.  This will allow me to move forward.

The documentation is somewhat sparse on practical examples of how to use
the count and preceding-sibling type functions.

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

-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, August 09, 2007 11:21 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Problem with xsl:number formatting

At 2007-08-09 10:57 -0400, you wrote:
>Thanks for your response.  I get a different answer when I try your
>script.  When I view the file in Internet Explorer I get:

So do I (transcript below).

I guess I'd have to ask the committee for a judgement, but I have my own
analysis of the specification and I would judge this a bug in IE (there
are very few but some of them are gotchas).

XSLT 1.0 section 7.7.1 does talk about format tokens "A" and "a", but in
the second paragraph it states that the token can be *any* character
that has a Unicode category including "Ll" and "Lu"
(lower-case and upper-case letters), and that that the constructed
string will start with that token.  So I interpret the "A" and "a" as
merely example tokens.

So, in my mind, 'E' is a valid token on which to start.

If you are obliged to use IE then the code below would be a work-around
you could use.  It is a bit brute-force but it works in both Saxon and
IE.

I hope this helps.

. . . . . . . . . . Ken

T:\ftemp2>xslt-msxsl bruce.xml bruce.xsl bruce.ms

T:\ftemp2>type bruce.ms
<?xml version="1.0" encoding="UTF-16"?>1 CSU Category: Interface<br
/><br />1.1
CSU: Analog Input Interface<br />1.1.1 SWInterface: <br /><br />1.2 CSU:
Analog Output Interface<br />1.2.1 SWInterface: <br /><br />1.3 CSU:
Other Interface<br
  />1.3.1 SWInterface: <br />2 CSU Category: Interface<br /><br />2.1
CSU: Analog
  Input Interface<br />2.1.1 SWInterface: <br /><br />2.2 CSU: Analog
Output Inte rface<br />2.2.1 SWInterface: <br /><br />2.3 CSU: Other
Interface<br
/>2.3.1 SW
Interface: <br />3 CSU Category: Interface<br /><br />3.1 CSU: Analog
Input Inte rface<br />3.1.1 SWInterface: <br /><br />3.2 CSU: Analog
Output Interface<br />
3.2.1 SWInterface: <br /><br />3.3 CSU: Other Interface<br />3.3.1
SWInterface:
<br />4 CSU Category: Interface<br /><br />4.1 CSU: Analog Input
Interface<br />
4.1.1 SWInterface: <br /><br />4.2 CSU: Analog Output Interface<br
/>4.2.1 SWInt
erface: <br /><br />4.3 CSU: Other Interface<br />4.3.1 SWInterface: <br
/> T:\ftemp2>

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 bruce2.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:for-each select="ancestor::CSU_Category">
           <xsl:number format="A."
             value="count(preceding-sibling::CSU_Category)+5"/>
         </xsl:for-each>
         <xsl:number level="multiple" format="1"
count="CSU_Category|CSU" /> CSU: <xsl:value-of select="@Name"/>
         <br/>
         <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Template">
         <xsl:for-each select="ancestor::CSU_Category">
           <xsl:number format="A."
             value="count(preceding-sibling::CSU_Category)+5"/>
         </xsl:for-each>
         <xsl:number level="multiple" format="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 bruce2.xsl bruce.out

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


     <br/>E.1.2 CSU: Analog Output Interface<br/>
       E.1.2.1 SWInterface: <br/>


     <br/>E.1.3 CSU: Other Interface<br/>
       E.1.3.1 SWInterface: <br/>



   F CSU Category: Interface<br/>
     <br/>F.2.1 CSU: Analog Input Interface<br/>
       F.2.1.1 SWInterface: <br/>


     <br/>F.2.2 CSU: Analog Output Interface<br/>
       F.2.2.1 SWInterface: <br/>


     <br/>F.2.3 CSU: Other Interface<br/>
       F.2.3.1 SWInterface: <br/>



   G CSU Category: Interface<br/>
     <br/>G.3.1 CSU: Analog Input Interface<br/>
       G.3.1.1 SWInterface: <br/>


     <br/>G.3.2 CSU: Analog Output Interface<br/>
       G.3.2.1 SWInterface: <br/>


     <br/>G.3.3 CSU: Other Interface<br/>
       G.3.3.1 SWInterface: <br/>



   H CSU Category: Interface<br/>
     <br/>H.4.1 CSU: Analog Input Interface<br/>
       H.4.1.1 SWInterface: <br/>


     <br/>H.4.2 CSU: Analog Output Interface<br/>
       H.4.2.1 SWInterface: <br/>


     <br/>H.4.3 CSU: Other Interface<br/>
       H.4.3.1 SWInterface: <br/>




T:\ftemp2>rem Done!

T:\ftemp2>xslt-msxsl bruce.xml bruce2.xsl bruce.ms

T:\ftemp2>type bruce.ms
<?xml version="1.0" encoding="UTF-16"?>1 CSU Category: Interface<br
/><br />E.1.
1 CSU: Analog Input Interface<br />E.1.1.1 SWInterface: <br /><br
/>E.1.2 CSU: A
nalog Output Interface<br />E.1.2.1 SWInterface: <br /><br />E.1.3
CSU: Other In
terface<br />E.1.3.1 SWInterface: <br />2 CSU Category: Interface<br
/><br />F.2
.1 CSU: Analog Input Interface<br />F.2.1.1 SWInterface: <br /><br
/>F.2.2 CSU:
Analog Output Interface<br />F.2.2.1 SWInterface: <br /><br />F.2.3
CSU: Other I
nterface<br />F.2.3.1 SWInterface: <br />3 CSU Category: Interface<br
/><br />G.
3.1 CSU: Analog Input Interface<br />G.3.1.1 SWInterface: <br /><br
/>G.3.2 CSU:
  Analog Output Interface<br />G.3.2.1 SWInterface: <br /><br />G.3.3
CSU: Other
Interface<br />G.3.3.1 SWInterface: <br />4 CSU Category:
Interface<br /><br />H
.4.1 CSU: Analog Input Interface<br />H.4.1.1 SWInterface: <br /><br
/>H.4.2 CSU
: Analog Output Interface<br />H.4.2.1 SWInterface: <br /><br />H.4.3
CSU: Other
  Interface<br />H.4.3.1 SWInterface: <br /> T:\ftemp2>

--
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.