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

📄 ch13s135.html

📁 详细介绍了jboss3.0的配置等
💻 HTML
📖 第 1 页 / 共 2 页
字号:
import org.xml.sax.SAXException;

DocumentBuilder parser = null;
try
{
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 String docURI = ...;
 parser.parse(docURI);
}
catch(SAXException e)
{
 ...
}
catch(java.io.IOException e)
{
 ...
}
catch(ParserConfigurationException e)
{
 ...
}
catch(FactoryConfigurationError e)
{
 ...
}</pre></div><div class="figure"><p><a name="jaxp.howto.xslt.example"></a><b>Figure 13.34. Example XSLT Transformer Creation</b></p><pre class="programlisting">import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

Transformer transformer = null;
try
{
 TransformerFactory factory = TransformerFactory.newInstance();
 String stylesheet = "file:///ssheet.xsl";
 String xmldoc = "file:///application.xml";
 StreamSource style = new StreamSource(stylesheet);
 StreamSource src = new StreamSource(xmldoc);
 StreamResult result = new StreamResult(System.out);
 transformer = factory.newTransformer(style);
 transformer.transform(src, dest);
}
catch(TransformerFactoryConfigurationError e)
{
 ...
}
catch(TransformerConfigurationException e)
{
 ...
}
catch(TransformerException e)
{
 ...
}</pre></div></div><div class="section"><a name="d0e11959"></a><div class="titlepage"><div><h3 class="title"><a name="d0e11959"></a>Common Questions</h3></div></div><div class="qandaset"><dl><dt>1.  <a href="ch13s135.html#d0e11964" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s135.html#d0e11964">Do I have to use JAXP for xml parsing?</a></dt><dt>2.  <a href="ch13s135.html#d0e11971" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s135.html#d0e11971">Can I mix different xml parsers?</a></dt><dt>3.  <a href="ch13s135.html#d0e11978" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s135.html#d0e11978">What if I have to use an older parser that does not support JAXP?</a></dt></dl><div class="qandaentry"><div class="question"><p><a name="d0e11964"></a><b>1. </b>Do I have to use JAXP for xml parsing?</p></div><div class="answer"><p><a name="d0e11967"></a><b></b>Not necessarily. If you have a specific parser you want to use and you want to uses a parser specific factory you can as long as the parser supports JAXP as this is how JBoss is locating its xml parsers.</p></div></div><div class="qandaentry"><div class="question"><p><a name="d0e11971"></a><b>2. </b>Can I mix different xml parsers?</p></div><div class="answer"><p><a name="d0e11974"></a><b></b>If they are all support the same level of the xml standards and JAXP then you should be able to. However, if there are differences then you are likely to see a SecurityException("sealing violation") error thrown.</p></div></div><div class="qandaentry"><div class="question"><p><a name="d0e11978"></a><b>3. </b>What if I have to use an older parser that does not support JAXP?</p></div><div class="answer"><p><a name="d0e11981"></a><b></b>The you will need to use your own ClassLoader instance to isolate any common xml parser packages to avoid the sealing violation exception.</p></div></div></div></div></div><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="432" height="79"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch13s131.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s131.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch13s144.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s144.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table></body></html>

⌨️ 快捷键说明

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