I am using java to do these transforms.
Not sure if it supports 1 or 2, but I noticed that my XSL has the
following XML header:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
What is the 2.0 equivilant? Just:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
?
Thanks again-
Matt
try
{
TransformerFactory transformFactory = TransformerFactory.newInstance();
// Get params from URL.
Transformer transformer = null;
StreamSource xmlSource = null;
StreamSource xslSource = null;
// Get the XML input document.
if (xmlReader != null )
xmlSource = new StreamSource(xmlReader);
// Get the stylesheet.
if (xslReader != null )
xslSource = new StreamSource(xslReader);
System.out.println(" xslSource = "+xslSource);
System.out.println(" xmlSource = "+xmlSource);
if (xmlSource != null) // We have an XML input document.
{
if (xslSource == null) // If no stylesheet, look for PI in
XML input document.
{
System.out.println("stylesheet was null, getting
associated stylesheet");
String media= null;
String title = null;
String charset = null;
xslSource = (StreamSource)
transformFactory.getAssociatedStylesheet(xmlSource, media, title,
charset);
}
if (xslSource != null) // Now do we have a stylesheet?
{
System.out.println("Creating transformer from xsl
source");
transformer = transformFactory.newTransformer(xslSource);
// setParameters(transformer, request); // Set
stylesheet params.
// Perform the transformation.
System.out.println("doing transform and outputting to
writer");
transformer.setOutputProperty(OutputKeys.ENCODING,
"UTF-8");
transformer.transform(xmlSource, new StreamResult(out));
} else {
out.write("Missing stylesheet");
}
} else {
out.write("Missing XML input document");
}
}
catch (Exception e)
{
e.printStackTrace(new PrintWriter(out));
}
On 3/13/07, Kamal Bhatt <kbhatt(_at_)tt(_dot_)com(_dot_)au> wrote:
Michael Kay wrote:
> You mean, truncate it to a certain number of words?
>
> In XSLT 2.0, that's
>
> tokenize($in, '\W')[position() = 1 to $n]
>
> where $in is your input string and $n is the number of words.
>
> It's a fair bit harder in XSLT 1.0 (most things are).
>
Depends if your 1.0 parser supports str:tokenize (a EXSLT function). If
it does, then it not a "fair bit harder" but it will be "a wee bit
harder" :)
See here:
http://www.exslt.org/str/functions/tokenize/index.html
I think Xalan supports this function if you are using it.
--
Kamal Bhatt
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--