[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: filter using contains with multiple values
wow getting more and more complex! Yes I had still stylesheet version 1.0 there - ups, but even using exactly your stylesheet declarations I still do not succeed! So I guess the problem must be elsewhere. To give you the full picture: The code we are talking about is a XSL stylesheet is used by a servlet passing in the filter stuff in using transformer.setParameter and filter_values are passed to the servlet using javascript. So to get to the bottom of the problem I inserted the filter_values directly into the setParameter and now see the following: transformer.setParameter("filter", "keywords"); transformer.setParameter("filter_values", "Log"); works fine as expected! But: transformer.setParameter("filter_values", b'Log'"); (note the single quotes on the second argument of the filter_values!) Doesnbt work! So it looks like the quotes are passed to the xls:parameter and on doesnbt get a match on Logging (but would on bLoggingb)! So passing the parameters using: transformer.setParameter("filter_values", bbLogb, bInfo'b); does also not work - as one would now naturally expect! So one could think of passing them using: transformer.setParameter("filter_values", bLog, Infob); (which does not work either) but here I guess the whole second argument is interpreted as one single string (object) and I knew in advance that this is not meant to be working! So at this point I guess Ibm faced with the topic of 1) which transformer implementation one is using (I believe itbs Saxon - but am I sure?) and 2) how this implementation is handling the second argument of the setParameter (which is of type Object). Is there a easy way out e.g. how would one have to quote the argument if it is a complex string like the one Ibm aiming for? These are the details an I get from the tomcat servlet engine: Saxon version: 9.1.0.8 Version and details of JAXP b" DocumentBuilderFactory implementation: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl loaded from: Java Runtime b" XPathFactory implementation: org.apache.xpath.jaxp.XPathFactoryImpl loaded from: Java Runtime b" TransformerFactory implementation: net.sf.saxon.TransformerFactoryImpl loaded from: Java Runtime b" SAXParserFactory implementation: org.apache.xerces.jaxp.SAXParserFactoryImpl loaded from: Java Runtime which always confused me (why do I get this mixture of org.apache. and net.sf.saxon?) > > Are you sure you are using an XSLT 2.0 processor with the > <xsl:stylesheet version="2.0" > ? The xsl:value-of results sounds as if you have the wrong version attribute on your xsl:stylesheet or xsl:transform (or somewhere in your code you set xsl:version to 1.0). > > For me > > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" > xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> > > <xsl:param name="filter" as="xs:string" select="'keyword'"/> > <xsl:param name="filter_values" as="xs:string*" select="'Log', 'Info'"/> > > <xsl:template match="/"> > <xsl:copy-of select="//*[name() = $filter and . = $filter_values]"/> > </xsl:template> > > > </xsl:transform> > > when run against > > <list> > <entry> > <keyword>Log</keyword> > <location>A</location> > </entry> > <entry> > <keyword>Log</keyword> > <location>B</location> > </entry> > <entry> > <keyword>Problem</keyword> > <location>A</location> > </entry> > <entry> > <keyword>Info</keyword> > <location>B</location> > </entry> > </list> > > with Saxon 9 (see online at http://xsltransform.net/gWvjQg1) returns the three elements > > <keyword>Log</keyword><keyword>Log</keyword><keyword>Info</keyword> > > > The contains check with "some" would be > > <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" > xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"> > > <xsl:param name="filter" as="xs:string" select="'keyword'"/> > <xsl:param name="filter_values" as="xs:string*" select="'Log', 'Info'"/> > > <xsl:template match="/"> > <xsl:copy-of select="//*[name() = $filter and (some $value in $filter_values satisfies contains(., $value))]"/> > </xsl:template> > > > </xsl:transform> > > with the sample > > <list> > <entry> > <keyword>Log</keyword> > <location>A</location> > </entry> > <entry> > <keyword>Log</keyword> > <location>B</location> > </entry> > <entry> > <keyword>Problem</keyword> > <location>A</location> > </entry> > <entry> > <keyword>The newest Info</keyword> > <location>B</location> > </entry> > </list> > > > giving > > <keyword>Log</keyword><keyword>Log</keyword><keyword>The newest Info</keyword> > > (Online at http://xsltransform.net/gWvjQg1/1)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|