Ah, good point. Here you go:

Examples XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:java="http://xml.apache.org/xslt/java " xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="/">
   <xsl:apply-templates/>
</xsl:template>

<xsl:template match="begin">
    <xsl:if test="$system-interface = 'publish'">
        <publish>publish content</publish>
    </xsl:if>
    <xsl:if test="$system-interface = 'admin'">
        <cms>in cms</cms>
    </xsl:if>
</xsl:template>
</xsl:stylesheet>
The Java code we're using to validate:
String xslt;
TransformerFactory transformerFactory = new org.apache.xalan.processor.TransformerFactoryImpl(); transformerFactory.newTemplates(new SAXSource(new InputSource(new BufferedReader(new StringReader(xslt))))); The string "xslt" is their stylesheet like the example above. "system- interface" is the name of the parameter we're passing to the transformer for their use.
Thanks!
On Oct 2, 2008, at 6:07 PM, [EMAIL PROTECTED] wrote:


Guess: Sounds like the problem is in how you're asserting those parameters and/or how you've declared them in the stylesheet.

Hard to say anything more useful without seeing that code.

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (http://www.ovff.org/pegasus/songs/threes-rev-11.html )


Bradley Wagner <[EMAIL PROTECTED]>
10/02/2008 05:36 PM

To
[email protected]
cc
Subject
Validating XSLT by building a Templates or Transformer object





Hi, we're currently validating XSLTs submitted by our users by using the org.apache.xalan.processor.TransformerFactoryImpl to create new Templates objects with TransformerFactory.newTemplates(Source). The problem is that when we actually apply these XSLT stylesheets we pass transformer parameters that our XSLT writers can use.

We're running into problems because we can't figure out how to validate the XSLTs while passing these parameters in. I keep getting errors saying that the validation failed because: Could not find variable with the name of system-interface (the name of one of our parameters).

Any ideas?

Thanks,
Bradley

Reply via email to