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

Re: problem with xsl:copy-of and counting lines

Subject: Re: problem with xsl:copy-of and counting lines
From: Andreas Peter <info@xxxxxxxxxx>
Date: Wed, 20 Jun 2007 14:07:32 +0200
Re:  problem with xsl:copy-of and counting lines
Quoting David Carlisle <davidc@xxxxxxxxx>:

But if I want to use the value of the string for other operations I
have to declare a global variable, right?

it depends what you want to do with it, I'd say 999 times out of a 1000 when users ask about variable usage the answer to the real underlying problem doesn't involve the use of variables at all.

If it is a global variable it has a global value, but i thought you
wanted different values calculated on different blocks.

Is it possible to match the node of an external document like
<xsl:template match="document('variables.xsl')/block"> or something
 like this?

You are mixing up the concepts of matching and selecting. a maych pattern says, more or less 2if you happen to come across a node that looks like this, do the following". It's Xpath expressions in select attributes that actually steer the processor to look in different places.

so you'd want

<xsl:template match="block">

then at some point if you want to process the other doc, do

<xsl:apply-templates select="document('variables.xsl')"/>


<xsl:apply-templates select="document('variables.xsl')/block"/>

or whataver's needed in your case.

The variables.xsl file looks like this:

oops that's xslt not an input file (although of course you can input xslt as data, it doesn't execute in that case)

To spread your stylesheet code across multiple docu,emts you don't use
document() you use xsl:import or xsl:include but these are compile time
constructs the whole stylesheet is constructed by importing teh
necessary .xsl files _before_ any transformation actually runs.

Take 10 steps back.

What problem are you trying to solve, just state it in english, without
assuming that the solution requires the use of xsl:variable.

I am just waiting for Michael
Kays two books about XPath 2.0 and XSLT 2.0 for helping me with the

are you using XSLT2 (all answers given so far assume the use of XSLt1) there are easier ways of counting lines in xslt2 as it has regular expression support.

Also, _why_ do you want to count all the lines in an xml file, ignoring
the XML structure, if that's what you really need it would seem to be
easier to use a non xml tool, wc -l for example.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.

Okay, 10 steps back. At the moment I am working on my diploma for my degreed engineer. I wanted to do something with xml and some transformations.

The source object is an printed broschure which was generated in
InDesign. I want to create a more automated possibility for ceating
the print data. Thats why I "try" to learn XSL(T) because the source
data comes from a database as xml files.

The main problem is that the document has a more or less complex structure.
For example every page has a different number of lines. If there is a
less number of lines than the maximum number of lines on a page the
rest of the page will be filled by announcements or sth else from a
pool of grafics.

My suggestion was: page height minus the lines of a certain group of
elements so that I can see if there is enough space for an
announcement or not.

At the beginning of the project I was very enthusiastic but now I
realise how much programmers know how is behind the "small" broschure.
And I am not a real programmer. My first contact with programming.

Thanks for listening :-) and helping.

Current Thread


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.
First Name
Last Name
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.