@SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory();
@SuppressWarnings("unchecked") public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException { if (sourceClass == null || sourceClass == StreamSource.class) { return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId()); } else if (sourceClass == StAXSource.class) { XMLInputFactory factory = XMLType.getXmlInputFactory();
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); } }
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); } }
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); } }