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

RE: Call-Template confusion

Subject: RE: Call-Template confusion
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 2 Oct 2000 10:23:26 +0100
RE: Call-Template confusion
> I'm trying to transform an input XML doc to an internal 
> format my company uses, and I have a couple of questions.

> First off
> The input XML docs arrive with a document type declaration, 
> so  to transform 
> them (we don't care about their validity-that will have been 
> done before they 
> reach us by the client), must the processor (xt) have access 
> to the dtd?

First make sure the XSLT processor is using an XML parser that isn't
validating, or has validation switched off.

There might still be an overhead simply in reading the DTD, so if validation
is off you could try substituting a minimal DTD that simply contains any
necessary entity declarations. The substitute doesn't need to have the same
name, you could achieve the substitution for example by writing an
EntityResolver as a plug-in to the XML parser.

> The result must have selected nodes converted to text, in a 
> specific position ...
> Could a call-template be written that took two parameters (a 
> string, and a 
> number) return the string with empty spaces appended to the 
> end so that it 
> occupied the number of spaces specified by the number 
> parameter?  

So long as you know the number of spaces will never exceed say 100, write

<xsl:template name="pad">
<xsl:param name="s"/>
<xsl:param name="len"/>
<xsl:variable name="spaces">         ...                   </xsl:variable>
<xsl:value-of select="substring(concat($s, $spaces), 1, $len)"/>
</xsl:template>
 
A more elegant solution, which handles any number of spaces, is for the
template to append one space to the string and then call itself to add
another "len-1", until len reaches zero.

Mike Kay


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


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.