jd.xml.xslt
Class Stylesheet

java.lang.Object
  extended byjd.xml.xslt.Transformation
      extended byjd.xml.xslt.AbstractStylesheet
          extended byjd.xml.xslt.Stylesheet

public class Stylesheet
extends AbstractStylesheet

Stylesheet represents a XSL stylesheet. To transform a xml file you have to

For instance the following code fragment transforms "in.xml" to "out.xml" using the stylsheet "transform.xsl":
 Stylesheet stylesheet = new Stylesheet();
 stylesheet.setup(new XmlSource("transform.xsl"));

 XmlSource xmlIn   = new XmlSource("in.xml");
 XsltResult xmlOut = new XsltResult("out.xml");
 stylesheet.transform(xmlIn, xmlOut);
 
The various constructors of XmlSource and XsltResult allow you to specify different sources or destinations of the transformation (files, inputstreams, urls, DOM documents).

See Also:
XmlSource, XsltResult, AbstractStylesheet.transform(jd.xml.util.XmlSource, jd.xml.xslt.XsltResult, int)

Nested Class Summary
static class Stylesheet.CmdLine
           
 
Field Summary
static String VERSION
          The jd.xslt version.
 
Fields inherited from class jd.xml.xslt.AbstractStylesheet
decimalFormatSymbols_, keys_, messageListener_, nodeNamePool_, outputFormat_, securityManager_, verboseLog_, warningLevel_
 
Constructor Summary
Stylesheet()
           
 
Method Summary
 void clearParameters()
          Clear the values of a all top-level parameters.
protected  boolean isSetup()
          Test if the stylesheet has been initialized.
static void main(String[] args)
          Command line interface.
 void setEntityResolver(EntityResolver entityResolver)
          Set the EntityResolver.
protected  boolean setParameterInternal(String name, XObject value)
          Set the value of an global parameter.
 void setTrace(boolean trace)
          Set if transformations should be traced.
 void setup(StylesheetData data)
          Setup the stylesheet from the given stylesheet data.
 void setup(XmlSource xslSource)
          Setup the stylesheet from the given stylesheet document.
 void setUriResolver(UriResolver uriResolver)
          Set a UriResolver.
 void setValidate(boolean validate)
          Set if xml documents should be validated.
protected  void transformInternal(XmlSource source, XsltResult result, int repeat)
          Transform the source to the result.
 
Methods inherited from class jd.xml.xslt.AbstractStylesheet
getNodeNamePool, getOutputFormat, setMessageListener, setParameter, setParameter, setSecurityManager, setVerboseLog, setWarningLevel, transform
 
Methods inherited from class jd.xml.xslt.Transformation
setVerbose, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
The jd.xslt version.

See Also:
Constant Field Values
Constructor Detail

Stylesheet

public Stylesheet()
Method Detail

setup

public void setup(XmlSource xslSource)
           throws IOException,
                  SAXException,
                  XsltParseException
Setup the stylesheet from the given stylesheet document.

Throws:
IOException - thrown if the stylesheet document cannot be read
SAXException - thrown if the stylesheet document cannot be parsed
jd.xml.xslt.XsltParseException - thrown if the stylesheet contains syntax errors
XsltParseException

setup

public void setup(StylesheetData data)
Setup the stylesheet from the given stylesheet data.


isSetup

protected boolean isSetup()
Test if the stylesheet has been initialized.

Specified by:
isSetup in class AbstractStylesheet
See Also:
setup(jd.xml.util.XmlSource)

setParameterInternal

protected boolean setParameterInternal(String name,
                                       XObject value)
Description copied from class: AbstractStylesheet
Set the value of an global parameter. The method is only called if isSetup returns true.

Specified by:
setParameterInternal in class AbstractStylesheet
Returns:
return if the parameter was defined in the stylesheet

clearParameters

public void clearParameters()
Clear the values of a all top-level parameters.

Specified by:
clearParameters in class Transformation

setUriResolver

public void setUriResolver(UriResolver uriResolver)
Set a UriResolver.

Specified by:
setUriResolver in class Transformation

setValidate

public void setValidate(boolean validate)
Set if xml documents should be validated.

Specified by:
setValidate in class Transformation

setTrace

public void setTrace(boolean trace)
Set if transformations should be traced.

Specified by:
setTrace in class Transformation

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)
Set the EntityResolver.

Specified by:
setEntityResolver in class Transformation

transformInternal

protected void transformInternal(XmlSource source,
                                 XsltResult result,
                                 int repeat)
                          throws Exception
Transform the source to the result.

Specified by:
transformInternal in class AbstractStylesheet
Parameters:
source - the transformation source
result - the transformation result
repeat - repeat the transformation n times. A repeat value greater
Throws:
IOException - if an I/O error occurrs
SAXException - if the source document cannot be parsed
XsltException - if a transformation error occurrs
Exception

main

public static void main(String[] args)
Command line interface.