public Document downConvertDOM(Document document) { /* If inlining CSS, create a document to hold the name/value pairs as described in * buildCSSPropertiesDocument(). Otherwise, we'll create an empty one to indicate * that nothing should be inlined */ Document cssPropertiesDocument = XMLUtilities.createNSAwareDocumentBuilder().newDocument(); if (cssProperties!=null) { buildCSSPropertiesDocument(cssPropertiesDocument, cssProperties); } /* Create URI Resolver to let the XSLT get at this document */ CSSPropertiesURIResolver uriResolver = new CSSPropertiesURIResolver(cssPropertiesDocument); /* Run the conversion XSLT */ Templates templates = stylesheetManager.getStylesheet(Globals.MATHML_TO_XHTML_XSL_RESOURCE_NAME); Document result = XMLUtilities.createNSAwareDocumentBuilder().newDocument(); try { Transformer transformer = templates.newTransformer(); transformer.setURIResolver(uriResolver); transformer.transform(new DOMSource(document), new DOMResult(result)); } catch (Exception e) { throw new SnuggleRuntimeException("Unexpected Exception down-converting DOM", e); } return result; }
public Document downConvertDOM(Document document) { /* If inlining CSS, create a document to hold the name/value pairs as described in * buildCSSPropertiesDocument(). Otherwise, we'll create an empty one to indicate * that nothing should be inlined */ Document cssPropertiesDocument = XMLUtilities.createNSAwareDocumentBuilder().newDocument(); if (cssProperties!=null) { buildCSSPropertiesDocument(cssPropertiesDocument, cssProperties); } /* Create URI Resolver to let the XSLT get at this document */ CSSPropertiesURIResolver uriResolver = new CSSPropertiesURIResolver(cssPropertiesDocument); /* Run the conversion XSLT */ Templates templates = stylesheetManager.getCompiledStylesheet(Globals.MATHML_TO_XHTML_XSL_RESOURCE_NAME); Document result = XMLUtilities.createNSAwareDocumentBuilder().newDocument(); try { Transformer transformer = templates.newTransformer(); transformer.setURIResolver(uriResolver); transformer.transform(new DOMSource(document), new DOMResult(result)); } catch (Exception e) { throw new SnuggleRuntimeException("Unexpected Exception down-converting DOM", e); } return result; }
public Document downConvertDOM(Document document) { /* If inlining CSS, create a document to hold the name/value pairs as described in * buildCSSPropertiesDocument(). Otherwise, we'll create an empty one to indicate * that nothing should be inlined */ Document cssPropertiesDocument = XMLUtilities.createNSAwareDocumentBuilder().newDocument(); if (cssProperties!=null) { buildCSSPropertiesDocument(cssPropertiesDocument, cssProperties); } /* Create URI Resolver to let the XSLT get at this document */ CSSPropertiesURIResolver uriResolver = new CSSPropertiesURIResolver(cssPropertiesDocument); /* Run the conversion XSLT */ Templates templates = stylesheetManager.getStylesheet(Globals.MATHML_TO_XHTML_XSL_RESOURCE_NAME); Document result = XMLUtilities.createNSAwareDocumentBuilder().newDocument(); try { Transformer transformer = templates.newTransformer(); transformer.setURIResolver(uriResolver); transformer.transform(new DOMSource(document), new DOMResult(result)); } catch (Exception e) { throw new SnuggleRuntimeException("Unexpected Exception down-converting DOM", e); } return result; }