net.sf.saxon.TransformerFactoryImpl
What I want to do and I don’t know if it’s possible is to pass the variable to the stylesheet, which contains the path to the directory where my XML files are stored. I want to pass this variable from my Java code.
<xsl:for-each select="for $x in(collection('MYVAR?select=*.xml;recurse=yes')) return saxon:discard-document($x)//testsuites">
Just use
<xsl:for-each select="for $x in(collection(concat($MYVAR, '?select=*.xml;recurse=yes')))return saxon:discard-document($x)//testsuites">
Please note that MYVAR should be the URL of the file, not the directory of the directory (platform dependent).
[edit] In your XSLT you need
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:param name="MYVAR"/> ... </xsl:stylesheet>
Java http://download.oracle.com/javase/6/docs/api/javax/xml/transform/Transformer.html#setParameter%28java.lang.String,%20java.lang.Object%29, .
transformer.setParameter("MYVAR", "file:///C:/dir/subdir/dir");
:
<xsl:param name="MYVAR" />
Java, , :
transformer.setParameter("MYVAR", 'file:/some/folder');
, :
<xsl:for-each select="for $x in (collection(concat($MYVAR, '?select=*.xml;recurse=yes'))) return saxon:discard-document($x)//testsuites">
Source: https://habr.com/ru/post/1789981/More articles:Android, want to link bitmaps in an array using strings, programmatically - androidAdditional tools / scripts / plugins for editing html with vim - htmlPutting datatable values separated by commas in a string - c #MVC - passing additional information to a view - c #Android - disable pinch zoom control in google maps API - javaEF Codefirst How to create a separate table for a derived class? - c #Animate Path Fill - Silverlight - animationYoutube Player Cannot Be Covered With Any HTML Element - iphoneHow to avoid PHP exec () using WSGI to execute a Python script? - pythonEF Codefirst How to create a key from multiple columns using DataAnnotations - c # -4.0All Articles