|
Subject: [xsl] XSL java extension newbie question From: "sivaram g" <raviyellanet@xxxxxxxxxxx> Date: Thu, 02 Oct 2003 19:38:33 +0000 |
<items>
<item>
<name>a</name>
</item>
<item>
<name>b</name>
</item>
</item>public class MyTest
{
int itemsCount=0;
public void foundItem()
{
itemsCount++;
}
}my main reads...
public static void main (String[]args)
{
String xmlFile = "input.xml";
String xslFile = "input.xsl";
MyTransformer myt;
Source xml;
Source xsl;
Result result = new StreamResult (System.out);
HashMap params = new HashMap (); try
{
myt = new MyTransformer ();
xml = myt.SourceFromFilename (xmlFile);
xsl = myt.SourceFromFilename (xslFile);
params.put ("changeme", x);
myt.transform (xml, xsl, result, params);
System.out.println("%%%%%%%%%%%\n"+x.itemsCount);
} catch (Exception e)
{
System.out.println ("Exception: " + e.getMessage ());
}and the xsl reads as <?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:mytest="MyTest" extension-element-prefixes="mytest"> <xsl:param name="changeme" /> <xsl:template match="/"> <!-- this does print the object as in main --> <xsl:value-of select="$changeme"/> <xsl:apply-templates select="items"> <xsl:with-param name="changeme" select="$changeme" /> </xsl:apply-templates> </xsl:template> <xsl:template match="items"> <xsl:apply-templates select="item"> </xsl:apply-templates> </xsl:template> <xsl:template match="item"> <xsl:value-of select="mytest:foundItem()"/> </xsl:template>
thanks sivaram
| Current Thread |
|---|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] slightly OT: php and xsl-, fe . sola | Thread | Re: [xsl] XSL java extension newbie, Tim Meals |
| Re: [xsl] slightly OT: php and xsl-, J.Pietschmann | Date | RE: [xsl] A way to use Single quote, David Carlisle |
| Month |