⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsl-api.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="XSL API"><p>Applying XSL is a multi-step process:</p><ol><li>Create a javax.xml.transform.TransformerFactory<li>Parse a javax.xml.transform.Templates (Stylesheet)<li>Create a javax.xml.transform.Transformer<li>Set any XSL variables<li>Create a javax.xml.transform.Source for the input.<li>Create a javax.xml.transform.Result for the output.<li>Call transform() to transform the input to the output.</ol><p>The transformers let you select the output format appropriate foryour application: output stream, string, or node.  In addition, eachtransformer instance lets you set XSL parameters (i.e. parameters setby xsl:param.)</p><example title="Java API for XSL transform">import java.io.*;import javax.xml.transform.*;import javax.xml.transform.stream.*;import com.caucho.vfs.*;import com.caucho.xml.*;import com.caucho.xsl.*;public class Test {  public static void main(String []args)    throws Exception  {    TransformerFactory factory = TransformerFactory.newInstance();    StreamSource xslSource = new StreamSource("test.xsl");    // Load the stylesheet.  If it's already compiled, Resin will just    // load the compiled class.  More sophisticated application will    // cache the Templates object.    Templates stylesheet = factory.newTemplates(xslSource);    // Create a transformer.  This could also be called from a    // cached Templates object.  The Transformer should not be cached.    Transformer transformer = stylesheet.newTransformer();    // Sets a parameter for the xsl:param "source"    transformer.setParameter("source", "java");    // The source is a file.    StreamSource source = new StreamSource("test.xml");    // The result is a file.    StreamResult result = new StreamResult("test.html");    transformer.transform(source, result);  }}</example><s2 title="Configuring JAXP for Xalan"><p>JAXP is a standard interface which supports pluggable XML and XSLimplementations.  JAXP selects the parser based onsystem properties.  You can set the properties to selecta different parser than the default one.</p><deftable title="JAXP Properties for Resin"><tr><th>system property<th>Resin value<tr><td>javax.xml.parsers.DocumentBuilderFactory    <td>com.caucho.xml.parsers.XmlDocumentBuilderFactory<tr><td>javax.xml.parsers.SAXParserFactory    <td>com.caucho.xml.parsers.XmlSAXParserFactory<tr><td>javax.xml.transform.TransformerFactory    <td>com.caucho.xsl.Xsl</deftable><deftable title="JAXP Properties for Xalan/Xerces"><tr><th>system property<th>Xerces value<tr><td>javax.xml.parsers.DocumentBuilderFactory    <td>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl<tr><td>javax.xml.parsers.SAXParserFactory    <td>org.apache.xerces.jaxp.SAXParserFactoryImpl<tr><td>javax.xml.transform.TransformerFactory    <td>org.apache.xalan.processor.TransformerFactoryImpl</deftable><p>The resin.conf and web.xml will let you configure system properties ona per-application basis.</p></s2><s2 title="Summary"><ul><li><var/Transformers/> select different output formats.</ul></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -