|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.xml.transform.sax.SAXSource
com.thoughtworks.xstream.io.xml.TraxSource
public class TraxSource
A JAXP TrAX Source
that enables using XStream object serialization as
direct input for XSLT processors without resorting to an intermediate representation such as
text XML, DOM or DOM4J.
source
):
public static String transform(List source, String stylesheet) {
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer(
new StreamSource(stylesheet));
TraxSource in = new TraxSource(source);
Writer out = new StringWriter();
transformer.transform(in, new StreamResult(out));
return out.toString();
} catch (TransformerException e) {
throw new RuntimeException("XSLT Transformation failed", e);
}
}
Field Summary | |
---|---|
static String |
XSTREAM_FEATURE
If TransformerFactory.getFeature(java.lang.String) returns true
when passed this value as an argument, the Transformer natively supports XStream. |
Fields inherited from class javax.xml.transform.sax.SAXSource |
---|
FEATURE |
Constructor Summary | |
---|---|
TraxSource()
Creates a XStream TrAX source. |
|
TraxSource(List source)
Creates a XStream TrAX source, setting the objects to marshal. |
|
TraxSource(List source,
XStream xstream)
Creates a XStream TrAX source, setting the objects to marshal and a configured (with aliases) XStream facade. |
|
TraxSource(Object source)
Creates a XStream TrAX source, specifying the object to marshal. |
|
TraxSource(Object source,
XStream xstream)
Creates a XStream TrAX source, specifying the object to marshal and a configured (with aliases) XStream facade. |
Method Summary | |
---|---|
XMLReader |
getXMLReader()
Returns the XMLReader to be used for the Source. |
void |
setInputSource(InputSource inputSource)
Sets the SAX InputSource to be used for the Source. |
void |
setSource(Object obj)
Sets the object to marshal. |
void |
setSourceAsList(List list)
Sets the list of objects to marshal. |
void |
setXMLReader(XMLReader reader)
Set the XMLReader to be used for the Source. |
void |
setXStream(XStream xstream)
Sets the XStream facade to use when marshalling objects. |
Methods inherited from class javax.xml.transform.sax.SAXSource |
---|
getInputSource, getSystemId, setSystemId, sourceToInputSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String XSTREAM_FEATURE
TransformerFactory.getFeature(java.lang.String)
returns true
when passed this value as an argument, the Transformer natively supports XStream.
Note: This implementation does not override the
SAXSource.FEATURE
value defined by its superclass to be considered as a SAXSource
by Transformer implementations not natively supporting this XStream-specific source
Constructor Detail |
---|
public TraxSource()
public TraxSource(Object source)
source
- the object to marshal.
IllegalArgumentException
- if source
is null
.setSource(java.lang.Object)
public TraxSource(Object source, XStream xstream)
source
- the object to marshal.xstream
- a configured XStream facade.
IllegalArgumentException
- if source
or xstream
is
null
.setSource(java.lang.Object)
,
setXStream(com.thoughtworks.xstream.XStream)
public TraxSource(List source)
source
- the list of objects to marshal.
IllegalArgumentException
- if source
is null
or
empty.setSourceAsList(java.util.List)
public TraxSource(List source, XStream xstream)
source
- the list of objects to marshal.xstream
- a configured XStream facade.
IllegalArgumentException
- if source
or xstream
is
null
or source
is empty.setSourceAsList(java.util.List)
,
setXStream(com.thoughtworks.xstream.XStream)
Method Detail |
---|
public void setInputSource(InputSource inputSource)
UnsupportedOperationException
.
setInputSource
in class SAXSource
inputSource
- a valid InputSource reference.
UnsupportedOperationException
- always!public void setXMLReader(XMLReader reader)
UnsupportedOperationException
if the provided reader object does not implement the SAX XMLFilter
interface.
Otherwise, a SaxWriter
instance will be attached as parent of the filter chain.
setXMLReader
in class SAXSource
reader
- a valid XMLReader or XMLFilter reference.
UnsupportedOperationException
- if reader
is not a SAX
XMLFilter
.getXMLReader()
public XMLReader getXMLReader()
SaxWriter
) generating the XML from a list of input objects.
getXMLReader
in class SAXSource
public void setXStream(XStream xstream)
xstream
- a configured XStream facade.
IllegalArgumentException
- if xstream
is null
.public void setSource(Object obj)
obj
- the object to marshal.
IllegalArgumentException
- if source
is null
.public void setSourceAsList(List list)
list
- the list of objects to marshal.
IllegalArgumentException
- if source
is null
or
empty.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |