org.vishia.xml
Class Xslt

java.lang.Object
  extended by org.vishia.xml.Xslt

public class Xslt
extends java.lang.Object

vishia XSLT Translator.

This translator calls the java-standard XSLT-engine defined with javax.xml.transform.TransformerFactory. The cmdLine-option -xslt:TRANSFORMER determines, which Transformer is used. The default-value is net.sf.saxon.TransformerFactoryImpl, therefore this Transformer is recommended to use. It should be provided by the adequate jar-File specified in the java's-CLASSPATH.

The vishia-XSLT prepares some inputs before calling the outside given Transformer:

Multiple inputs:
More as one XML-Inputfile is able to use as input. All input file-contents are disposed after a internal created < root> root-Element. It means, the translation file have to be regard this additional < root> root-Element. Write:

     < xsl:apply-templates match="/root" >
        ....
     
   
instead the often used
     < xsl:apply-templates match="/" >
        ....
     
   


Replacing of spaces of input:
The XML file representation may contain any white spaces (more as one space, line feed, indentation) between the XML-elements. It is a method of beautification of the appearance of the file content. The white spaces may be included by any XML-writer independent of the meaning of the content. But if the input should present a text with formatted inner elements (maybe XHTML), the white spaces may be interpreted as really text characters. The class XmlExtensions contains a static method org.vishia.xml.XmlExtensions.readXmlFileTrimWhiteSpace(File) which is used here if an input is designated with the cmdLine option -j:FILE.

Expansion of wikistyle:
This feature is not implemented yet. The conversion of WikistyleTextToSimpleXml is implemented instead in the ZBNF2Xml-conversion (class ZbnfXmlOutput and in the class CorrectHref for documentation generation. It was contained here in the past. It isn't supported yet, because the conversion routine is changed using the XmlNode, which is not directly compatible with JDOM. An adaption is existing in the XmlNodeJdom, but it isn't used here yet.

Beautification of output:
This feature was implemented here in the past before using the SAXON-XSLT. But the SAXON writes the file in an adequate style itself.

A beautification should generate indentation automatically. But it should regard textual contents: If any element contains a textual content, its whole content should be written in one line to prevent additional white spaces which may be confused the textual content. Such an XML-writer is implemented in org.vishia.xml.XmlExtensions.writeXmlBeautificatedTextFile(Element, File, Charset)}. This writer uses JDOM as input. This is the older implementation. A newer implementation of this feature is present in SimpleXmlOutputter.


Constructor Summary
Xslt()
           
 
Method Summary
static void main(java.lang.String[] args)
          main started from java.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Xslt

public Xslt()
Method Detail

main

public static void main(java.lang.String[] args)
main started from java.

Command line options:

      "invoke { -[i|j|k]:INPUT } [-t:XSLT] [-p:XSLP] -y:OUTPUT [-xslt:TRANSFORMER]");
      "-i:INPUT-XML-file");
      "-j:INPUT-XML-file, Whitespaces will replaced with 1 space");
      "-t:XSLT: xsl-script XML2-compatible, it is output if -p:XSLP is given");
      "-p:XSLP: Script pretranslated with Xsltpre, than -t:XSLT will be created if older.");
      "         If no option -t:XSLT is given, XSLT will be created parallel with .xsl as extension.");
      "-y:OUTPUT-file");
      "-xslt:TRANSFORMER Set the class for Transformer-Implementation. Default is " + sTransformer);