Using Java API in XSLT


XML & Web services: Using Java API in XSLT

  1. Using Java API in XSLT (3 messages)

    Hi, I want to use Java API in XSLT. I want to perform the following.

    <xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:xsi="" xmlns:java="------------">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
    <xsl:value-of select=""/>

    Can anyone let me know what exactly is the namespace to be mentioned for java (xmlns:java="-----")


    Threaded Messages (3)

  2. Using Java API in XSLT[ Go to top ]

    This is what I'd used:

    <xsl:stylesheet version="1.0"

    and transform the document like:

    TransformerFactory tFactory = TransformerFactory.newInstance();
    // Get the XML input document and the stylesheet.
    // Generate the transformer.
    Transformer transformer = tFactory.newTransformer(xslSource);

    //Write output
    File file = new File(outputDir, fileName);
    FileWriter writer = new FileWriter(file);
    StreamResult result = new StreamResult(writer);

    // Perform the transformation.
    transformer.transform(new DOMSource(document), result);

     - Deepak
  3. Using Java API in XSLT[ Go to top ]

    Hi Deepak,
    Thank you for the response.
    I had tried that xmlns:java="java". But it says to me "Namespace 'java' does not contain any functions".
    Somewhere on the web, i also saw java namespace mentioned as xmlns:java="". But i get the same error message.
    I am running this xslt as stand alone.
    I have written a sample xml and a stlesheet which displays the data.
    Let me know if you have any suggestions.

  4. Using Java API in XSLT[ Go to top ]

    This example works in both Xalan and Saxon XSLT processors (a static method call example) - it takes a string and formats it (the result is irrelevant):

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"

    <xsl:template match="/">
    Value: <xsl:value-of select="format:formatDateTime('20050101')"/>


    You just specify the class you want your "format:" prefix to use as above, no special Xalan conventions. Hope this helps.