Subject: RE: Call-Template confusion From: Kay Michael <Michael.Kay@xxxxxxx> Date: Mon, 2 Oct 2000 10:23:26 +0100 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Call-Template confusion, Mike Brown | Thread | XSLT and parallel processing, Erik Ray |
RE: Output is incorrect..., Kay Michael | Date | Re: XSLT and parallel processing, Tangi Vass |
Month |