@Override public String getString() throws SQLException { StringWriter sw = new StringWriter(); try { new StandardXMLTranslator(getSource(StAXSource.class)).translate(sw); } catch (TransformerException e) { throw new SQLException(e); } catch (IOException e) { throw new SQLException(e); } return sw.toString(); }
public void testStreamSourceWithStream() throws Exception { StandardXMLTranslator translator = new StandardXMLTranslator(new StreamSource(new StringReader(sourceXML))); compareDocuments(sourceXML, translator.getString()); }
StandardXMLTranslator sxt = new StandardXMLTranslator((Source)value); SQLXMLImpl sqlxml; try {
public static ClobType xslTransform(CommandContext context, Object xml, Object styleSheet) throws Exception { Source styleSource = null; Source xmlSource = null; try { styleSource = convertToSource(styleSheet); xmlSource = convertToSource(xml); final Source xmlParam = xmlSource; TransformerFactory factory = StandardXMLTranslator.getThreadLocalTransformerFactory(); final Transformer transformer = factory.newTransformer(styleSource); //this creates a non-validated sqlxml - it may not be valid xml/root-less xml SQLXMLImpl result = XMLSystemFunctions.saveToBufferManager(context.getBufferManager(), new XMLTranslator() { @Override public void translate(Writer writer) throws TransformerException { //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ // Feed the resultant I/O stream into the XSLT processor transformer.transform(xmlParam, new StreamResult(writer)); } }, context); return new ClobType(new ClobImpl(result.getStreamFactory(), -1)); } finally { WSUtil.closeSource(styleSource); WSUtil.closeSource(xmlSource); } }
StandardXMLTranslator sxt = new StandardXMLTranslator((Source)value); SQLXMLImpl sqlxml; try {
public static ClobType xslTransform(CommandContext context, Object xml, Object styleSheet) throws Exception { Source styleSource = null; Source xmlSource = null; try { styleSource = convertToSource(styleSheet); xmlSource = convertToSource(xml); final Source xmlParam = xmlSource; TransformerFactory factory = StandardXMLTranslator.getThreadLocalTransformerFactory(); final Transformer transformer = factory.newTransformer(styleSource); //this creates a non-validated sqlxml - it may not be valid xml/root-less xml SQLXMLImpl result = XMLSystemFunctions.saveToBufferManager(context.getBufferManager(), new XMLTranslator() { @Override public void translate(Writer writer) throws TransformerException { //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ // Feed the resultant I/O stream into the XSLT processor transformer.transform(xmlParam, new StreamResult(writer)); } }, context); return new ClobType(new ClobImpl(result.getStreamFactory(), -1)); } finally { Util.closeSource(styleSource); Util.closeSource(xmlSource); } }
StandardXMLTranslator sxt = new StandardXMLTranslator((Source)value); SQLXMLImpl sqlxml; try {
public static ClobType xslTransform(CommandContext context, Object xml, Object styleSheet) throws Exception { Source styleSource = null; Source xmlSource = null; try { styleSource = convertToSource(styleSheet); xmlSource = convertToSource(xml); final Source xmlParam = xmlSource; TransformerFactory factory = StandardXMLTranslator.getThreadLocalTransformerFactory(); final Transformer transformer = factory.newTransformer(styleSource); //this creates a non-validated sqlxml - it may not be valid xml/root-less xml SQLXMLImpl result = XMLSystemFunctions.saveToBufferManager(context.getBufferManager(), new XMLTranslator() { @Override public void translate(Writer writer) throws TransformerException { //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$ // Feed the resultant I/O stream into the XSLT processor transformer.transform(xmlParam, new StreamResult(writer)); } }, context); return new ClobType(new ClobImpl(result.getStreamFactory(), -1)); } finally { WSUtil.closeSource(styleSource); WSUtil.closeSource(xmlSource); } }