0
  1. My ${java.home} is C:\Program Files\Java\jdk1.7.0_51.
  2. I extracted saxonHE9-6-0-6J.zip in C:\Program Files\Java\jdk1.7.0_51\jre\lib\ext
  3. and add saxonhe9.jar to my classpath variable.
  4. Then I created a jaxp.properties file under C:\Program Files\Java\jdk1.7.0_51\jre\lib and add the following lines:

    javax.xml.transform.TransformerFactory = net.sf.saxon.TransformerFactoryImpl javax.xml.xpath.XPathFactory","net.sf.saxon.xpath.XPathFactoryImpl

For testing I use in my stylesheet the following lines

<xsl:for-each select="//*[@type='Usage']/@name">
  <xsl:value-of select="." separator="', '"/>
</xsl:for-each>

But the output of

StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);

is a string withoput commas.

StellaMaris
  • 877
  • 2
  • 12
  • 29
  • possible duplicate of [Can we do XSLT 2.0 with Netbeans 7?](http://stackoverflow.com/questions/6315260/can-we-do-xslt-2-0-with-netbeans-7) – Joe Jul 27 '15 at 09:48
  • You haven't said whether it worked, or if it didn't, how it failed. – Michael Kay Jul 27 '15 at 14:34

2 Answers2

2

I think you simply want <xsl:value-of select="//*[@type='Usage']/@name" separator=", "/> instead of

<xsl:for-each select="//*[@type='Usage']/@name">
  <xsl:value-of select="." separator="', '"/>
</xsl:for-each>

as the latter obviously will never output a separator given that you have the value-of inside of the for-each that ensures that . is a single item for the value-of.

Online sample at http://xsltransform.net/6qVRKx4 outputs name 1, name 3 for input sample

<root>
    <foo type="Usage" name="name 1"/>
    <foo type="Nonsense" name="name 2"/>
    <foo type="Usage" name="name 3"/>
</root>
Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
1

JAXP is an interface, not an implementation; and it embraces schema processing and XPath processing as well as XSLT processing.

There are several implementations of the JAXP transformation interface, including the built-in XSLT processor in the JDK, the two versions of Xalan that come in the Xalan-J product from Apache, the Oracle XSLT processor, and Saxon. Of these the only one that supports XSLT 2.0 is Saxon.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164