2012-09-03 51 views

回答

1

以下(未經測試)代碼應使用XML副本轉換提供所需的「橋」。

import javax.xml.transform.Transformer; 
import javax.xml.transform.TransformerFactory; 
import javax.xml.transform.stax.StAXSource; 
import javax.xml.transform.sax.SAXResult; 

void bridge(ContentHandler ch, XMLStreamReader sr) { 
    StAXSource src = new StAXSource(sr); 
    SAXResult res = new SAXResult(ch); 
    TransformerFactory tf = TransformerFactory.newInstance(); 
    Transformer tr = tf.newTransformer(); 
    tr.transform(src, res); 
} 
相關問題