OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

ubl-dev message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: Somewhat offtopic: xsl question

I agree this is off topic and would suggest that XSLT and XPath questions 
would be better posted to the following list:


There are a number of subscribers who would enthusiastically respond to 
such questions.

There is also an *excellent* FAQ at:


Meanwhile, back to your question ...

At 2004-05-26 10:38 +0100, Pedro Alves wrote:
>     I'm making a UBLInvoiceToEDIFACT stylesheet.

Kewl!  Which output vocabulary are you using to express the semantics of 
the EDIFACT message?

>I need to count the number
>of segments in the EDI file. What is the best way to do that in xsl (since
>the faqs say there is no direct way to define and change a global var)?

Yes, variables do not vary in XSLT, they are bound with an immutable value 
at declaration time.  This side-effect-free design decision sometimes makes 
for awkward approaches to traditionally-easy programming problems.  But it 
makes sense when you think that XSLT should not be treated as a programming 
language, but rather, as a templating language.

There are two ways to count nodes in the XPath node tree being acted upon 
by an XSLT stylesheet, depending on your context of where you are doing the 
counting and how you need to work with the resulting sum:

   <xsl:number/>  - this instruction counts nodes based on declared
                    properties of the nodes you want counted, but adds
                    the resulting value directly to the result tree

   count() - this function counts nodes based on addressed properties
             of the nodes you want counted, but the end result can be
             used in calculations or comparisons

On our web site we have two free download excerpts of XSL books that we 
sell ... you may find the reference material and summary material found in 
these free excerpts to be useful.  Follow the "Books & free excerpts" link 
in the marginalia.  These books form the basis of the world-wide corporate 
and public XSL teaching that I do.

>     I'm using javascript extensions, but would like to avoid that if
>possible .

I believe strongly that such extensions should be avoided at all costs.  In 
my UBL stylesheet work I am focusing on an XSLT 1.0-pure implementation and 
I am going through whatever contortions may be necessary to ensure no 
extensions are used in any way.

But future XSL-related questions should be sent to the above mailing 
list.  It may even be me answering if my volunteer time is being spent that 
day on that list.  The list does get heavy at times, so you may want to 
subscribe, get your answer, and unsubscribe again.  You may also find your 
answers directly in the archives of that list.

I hope this helps.

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

Public courses: Spring 2004 world tour of hands-on XSL instruction
Next: 3-day XSLT/XPath; 2-day XSL-FO - Birmingham, UK June 14,2004

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/u/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/u/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]