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.
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.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.