*/
private DOM getDOM(Source source)
throws TransformerException {
try {
DOM dom = null;
SAXImpl saxImpl = null;
DTMWSFilter wsfilter;
if (_translet != null && _translet instanceof StripFilter) {
wsfilter = new DOMWSFilter(_translet);
} else {
wsfilter = null;
}
boolean hasIdCall = (_translet != null) ? _translet.hasIdCall()
: false;
// Get systemId from source
if (source != null) {
_sourceSystemId = source.getSystemId();
}
if (source instanceof SAXSource) {
// Get all info from the input SAXSource object
final SAXSource sax = (SAXSource)source;
XMLReader reader = sax.getXMLReader();
final InputSource input = sax.getInputSource();
final boolean hasUserReader = reader != null;
// Create a reader if not set by user
if (reader == null) {
reader = _tfactory.getXMLReader();
}
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
if (_dtmManager == null) {
_dtmManager = XSLTCDTMManager.newInstance();
}
//dtmManager.setIncremental(_isIncremental);
saxImpl = (SAXImpl)_dtmManager.getDTM(sax, false, wsfilter, true, false,
hasUserReader, 0, hasIdCall);
//final DOMBuilder builder = ((SAXImpl)dom).getBuilder();
try {
reader.setProperty(LEXICAL_HANDLER_PROPERTY, saxImpl);
}
catch (SAXException e) {
// quitely ignored
}
reader.setContentHandler(saxImpl);
reader.setDTDHandler(saxImpl);
saxImpl.setDocumentURI(_sourceSystemId);
}
else if (source instanceof DOMSource) {
// Create a new internal DTM and build it directly from DOM
if (_dtmManager == null) {
_dtmManager = XSLTCDTMManager.newInstance();
}
//dtmManager.setIncremental(_isIncremental);
saxImpl = (SAXImpl)_dtmManager.getDTM(source, false, wsfilter, true,
false, hasIdCall);
saxImpl.setDocumentURI(_sourceSystemId);
}
// Handle StreamSource input
else if (source instanceof StreamSource) {
// Get all info from the input StreamSource object
final StreamSource stream = (StreamSource)source;
final InputStream streamInput = stream.getInputStream();
final Reader streamReader = stream.getReader();
final XMLReader reader = _tfactory.getXMLReader();
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
if (_dtmManager == null) {
_dtmManager = XSLTCDTMManager.newInstance();
}
//dtmManager.setIncremental(_isIncremental);
InputSource input;
if (streamInput != null) {
input = new InputSource(streamInput);
input.setSystemId(_sourceSystemId);
}
else if (streamReader != null) {
input = new InputSource(streamReader);
input.setSystemId(_sourceSystemId);
}
else if (_sourceSystemId != null)
input = new InputSource(_sourceSystemId);
else {
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR);
throw new TransformerException(err.toString());
}
saxImpl = (SAXImpl)_dtmManager.getDTM(new SAXSource(reader, input),
false, wsfilter, true,
false, hasIdCall);
saxImpl.setDocumentURI(_sourceSystemId);
}
else if (source instanceof XSLTCSource) {
final XSLTCSource xsltcsrc = (XSLTCSource)source;
if (_dtmManager == null) {
_dtmManager = XSLTCDTMManager.newInstance();