public class JAXBSource extends SAXSource
Source乘警JAXB生成对象。
本实用新型是JAXB类与其他java和XML技术的结合使用。
下面的示例演示如何使用JAXB元帅的XSLT文档转换。
MyObject o = // get JAXB content tree
// jaxbContext is a JAXBContext object from which 'o' is created.
JAXBSource source = new JAXBSource( jaxbContext, o );
// set up XSLT transformation
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource("test.xsl"));
// run transformation
t.transform(source,new StreamResult(System.out));
事实上,jaxbsource来自SAXSource是实现的细节。因此,在一般的应用是强烈阻止访问定义在SAXSource方法。特别是,该setxmlreader和setinputsource方法永远不会被称为。由getXMLReader方法来获得XmlReader对象应仅用于解析inputsource getinputsource方法返回的对象。
同样的getinputsource方法得到的inputsource对象应仅用于被解析的getxmlreader返回XmlReader对象。
| Constructor and Description |
|---|
JAXBSource(JAXBContext context, Object contentObject)
为给定的内容对象的一个新
Source。
|
JAXBSource(Marshaller marshaller, Object contentObject)
为给定的内容对象的一个新
Source。
|
getInputSource, getSystemId, getXMLReader, setInputSource, setSystemId, setXMLReader, sourceToInputSourcepublic JAXBSource(JAXBContext context, Object contentObject) throws JAXBException
Source。
context -送,用于创建
contentObject。这种情况下是用来创建一个新实例和指挥必须不为空。
contentObject -一个API实例生成的类,它将作为一个
Source(被编组为XML)。它不能为空。
JAXBException -如果遇到错误而创建的jaxbsource或如果参数是空的。
public JAXBSource(Marshaller marshaller, Object contentObject) throws JAXBException
Source。
marshaller -指挥实例,将用于
contentObject元帅为XML。这必须从送那是用来建立
contentObject不得空了。
contentObject -一个API实例生成的类,它将作为一个
Source(被编组为XML)。它不能为空。
JAXBException -如果遇到错误而创建的jaxbsource或如果参数是空的。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.