I'm using Saxon-CE to transform an XML File (XML to XML) based on a users's input. I have an XML File looking like this:
<?xml version="1.0" encoding="UTF-8"?>
<XML>
<Item name="i'm allowed"></Item>
<Item name="me too"></Item>
<Item name="not allowed"></Item>
<Item name="me neiter"></Item>
<XML>
I have a JavaScript function that filters an XML File based on the Items a user selected befor from checkboxes (in this case one selected "i'm allowed" and "me too"). I want to save the selection of the user and pass it to the XSLT 2.0 File as a variable:
<xsl:variable name="AllowedItems">
<Item name="i'm allowed"></Item>
<Item name="me too"></Item>
</xsl:variable>
so that I can use it in my XSL File with:
<xsl:param name="AllowedItems" />
Is there a possibility to realize this? What I have so far:
function TransformXML() {
xsltData = Saxon.requestXML("transformXML.xsl");
xmlData = Saxon.requestXML("myxml.xml");
var xsltProcessor = Saxon.newXSLT20Processor(xsltData);
xsltProcessor.importStylesheet(xsltData);
<!-- ?? xsltProcessor.setParameter(); ?? -->
var result = xsltProcessor.transformToDocument(xmlData);
}
Can I pass the parameter in another way? Maybe serialize the allowed.xsl? I'm not sure if there is a solution for this.
The problem is that I can't use the include function because I will have more "allowed.xsl" files and with include I can't choose the right file.
No comments:
Post a Comment