/** * Create a StylesheetHandler object, creating a root stylesheet * as the target. * * @param processor non-null reference to the transformer factory that owns this handler. * * @throws TransformerConfigurationException if a StylesheetRoot * can not be constructed for some reason. */ public StylesheetHandler(TransformerFactoryImpl processor) throws TransformerConfigurationException { Class func = org.apache.xalan.templates.FuncDocument.class; m_funcTable.installFunction("document", func); // func = new org.apache.xalan.templates.FuncKey(); // FunctionTable.installFunction("key", func); func = org.apache.xalan.templates.FuncFormatNumb.class; m_funcTable.installFunction("format-number", func); m_optimize =((Boolean) processor.getAttribute( TransformerFactoryImpl.FEATURE_OPTIMIZE)).booleanValue(); m_incremental = ((Boolean) processor.getAttribute( TransformerFactoryImpl.FEATURE_INCREMENTAL)).booleanValue(); m_source_location = ((Boolean) processor.getAttribute( TransformerFactoryImpl.FEATURE_SOURCE_LOCATION)).booleanValue(); // m_schema = new XSLTSchema(); init(processor); }
/** * Get the current stylesheet Locator object. * * @return non-null reference to the current locator object. */ public SAXSourceLocator getLocator() { if (m_stylesheetLocatorStack.isEmpty()) { SAXSourceLocator locator = new SAXSourceLocator(); locator.setSystemId(this.getStylesheetProcessor().getDOMsystemID()); return locator; // m_stylesheetLocatorStack.push(locator); } return ((SAXSourceLocator) m_stylesheetLocatorStack.peek()); }
/** * Receive notification of a recoverable XSLT processing error. * * @param e The error information encoded as an exception. * * @throws org.xml.sax.SAXException that wraps a * {@link javax.xml.transform.TransformerException} if the current * {@link javax.xml.transform.ErrorListener#error} * method chooses to flag this condition as an error. */ public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException { String formattedMsg = e.getMessage(); SAXSourceLocator locator = getLocator(); ErrorListener handler = m_stylesheetProcessor.getErrorListener(); try { handler.error(new TransformerException(formattedMsg, locator)); } catch (TransformerException te) { throw new org.xml.sax.SAXException(te); } }
/** * Create an XMLFilter that uses the given source as the * transformation instructions. * * @param src The source of the transformation instructions. * * @return An XMLFilter object, or null if this feature is not supported. * * @throws TransformerConfigurationException */ public XMLFilter newXMLFilter(Source src) throws TransformerConfigurationException { Templates templates = newTemplates(src); if( templates==null ) return null; return newXMLFilter(templates); }
/** * Get a TransformerHandler object that can process SAX * ContentHandler events into a Result, based on the transformation * instructions specified by the argument. * * @param src The source of the transformation instructions. * * @return TransformerHandler ready to transform SAX events. * * @throws TransformerConfigurationException */ public TransformerHandler newTransformerHandler(Source src) throws TransformerConfigurationException { Templates templates = newTemplates(src); if( templates==null ) return null; return newTransformerHandler(templates); }
/** * This method can be over-ridden by a class that extends this one. * @param handler The calling StylesheetHandler/TemplatesBuilder. */ protected Stylesheet getStylesheetRoot(StylesheetHandler handler) throws TransformerConfigurationException { StylesheetRoot stylesheet; stylesheet = new StylesheetRoot(handler.getSchema(), handler.getStylesheetProcessor().getErrorListener()); if (handler.getStylesheetProcessor().isSecureProcessing()) stylesheet.setSecureProcessing(true); return stylesheet; }
/** * Warn the user of an problem. * * @param msg An key into the {@link org.apache.xalan.res.XSLTErrorResources} * table, that is one of the WG_ prefixed definitions. * @param args An array of arguments for the given warning. * * @throws org.xml.sax.SAXException that wraps a * {@link javax.xml.transform.TransformerException} if the current * {@link javax.xml.transform.ErrorListener#warning} * method chooses to flag this condition as an error. * @xsl.usage internal */ public void warn(String msg, Object args[]) throws org.xml.sax.SAXException { String formattedMsg = XSLMessages.createWarning(msg, args); SAXSourceLocator locator = getLocator(); ErrorListener handler = m_stylesheetProcessor.getErrorListener(); try { if (null != handler) handler.warning(new TransformerException(formattedMsg, locator)); } catch (TransformerException te) { throw new org.xml.sax.SAXException(te); } }
/** * Report a fatal XSLT processing error. * * @param e The error information encoded as an exception. * * @throws org.xml.sax.SAXException that wraps a * {@link javax.xml.transform.TransformerException} if the current * {@link javax.xml.transform.ErrorListener#fatalError} * method chooses to flag this condition as an error. */ public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException { String formattedMsg = e.getMessage(); SAXSourceLocator locator = getLocator(); ErrorListener handler = m_stylesheetProcessor.getErrorListener(); try { handler.fatalError(new TransformerException(formattedMsg, locator)); } catch (TransformerException te) { throw new org.xml.sax.SAXException(te); } }
return processFromNode(node, baseID); else String messageStr = XSLMessages.createMessage( XSLTErrorResources.ER_ILLEGAL_DOMSOURCE_INPUT, null); TemplatesHandler builder = newTemplatesHandler(); builder.setSystemId(baseID); throw new org.xml.sax.SAXException(ex); throw new org.xml.sax.SAXException(ex1.toString()); m_errorListener.fatalError(new TransformerException(se)); throw new TransformerConfigurationException(se.getMessage(), se); m_errorListener.fatalError(new TransformerException(e)); return null;
/** * Receive notification of a XSLT processing warning. * * @param e The warning information encoded as an exception. * * @throws org.xml.sax.SAXException that wraps a * {@link javax.xml.transform.TransformerException} if the current * {@link javax.xml.transform.ErrorListener#warning} * method chooses to flag this condition as an error. */ public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException { String formattedMsg = e.getMessage(); SAXSourceLocator locator = getLocator(); ErrorListener handler = m_stylesheetProcessor.getErrorListener(); try { handler.warning(new TransformerException(formattedMsg, locator)); } catch (TransformerException te) { throw new org.xml.sax.SAXException(te); } }
URIResolver uriresolver = processor.getURIResolver(); throw new TransformerException(se); factory.setNamespaceAware( true ); if (handler.getStylesheetProcessor().isSecureProcessing()) throw new org.xml.sax.SAXException( ex ); } catch( javax.xml.parsers.FactoryConfigurationError ex1 ) { throw new org.xml.sax.SAXException( ex1.toString() ); handler.error(te.getMessage(), te);
ErrorListener handler = m_stylesheetProcessor.getErrorListener(); handler.error(new TransformerException(XSLMessages.createMessage(XSLTErrorResources.ER_ILLEGAL_XMLSPACE_VALUE, null), locator)); //"Illegal value for xml:space", locator)); throw new org.xml.sax.SAXParseException(te.getMessage(), locator, te);
TemplatesHandler builder = newTemplatesHandler(); TreeWalker walker = new TreeWalker(builder, new org.apache.xml.utils.DOM2Helper(), m_errorListener.fatalError(new TransformerException(se)); throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), se); m_errorListener.fatalError(new TransformerException(e)); throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), e); //"processFromNode failed",
Templates tmpl=newTemplates( source ); m_errorListener.fatalError( ex ); return null; // TODO: but the API promises to never return null...
if(attrDef.getName().compareTo("*")==0 && handler.getStylesheetProcessor().isSecureProcessing()) XSLMessages.createMessage( XSLTErrorResources.ER_REQUIRES_ATTRIB, new Object[]{ rawName, attrDef.getName() }), null);
/** * Get the Source object for the included or imported stylesheet module * obtained from the user's URIResolver, if there is no user provided * URIResolver null is returned. */ private Source getSourceFromUriResolver(StylesheetHandler handler) throws TransformerException { Source s = null; TransformerFactoryImpl processor = handler.getStylesheetProcessor(); URIResolver uriresolver = processor.getURIResolver(); if (uriresolver != null) { String href = getHref(); String base = handler.getBaseIdentifier(); s = uriresolver.resolve(href,base); } return s; }
/** * Process the stylesheet from a DOM tree, if the * processor supports the "http://xml.org/trax/features/dom/input" * feature. * * @param node A DOM tree which must contain * valid transform instructions that this processor understands. * @param systemID The systemID from where xsl:includes and xsl:imports * should be resolved from. * * @return A Templates object capable of being used for transformation purposes. * * @throws TransformerConfigurationException */ javax.xml.transform.Templates processFromNode(Node node, String systemID) throws TransformerConfigurationException { m_DOMsystemID = systemID; return processFromNode(node); }
/** * Warn the user of an problem. * * @param msg An key into the {@link org.apache.xalan.res.XSLTErrorResources} * table, that is one of the WG_ prefixed definitions. * @param args An array of arguments for the given warning. * * @throws org.xml.sax.SAXException that wraps a * {@link javax.xml.transform.TransformerException} if the current * {@link javax.xml.transform.ErrorListener#warning} * method chooses to flag this condition as an error. * @xsl.usage internal */ public void warn(String msg, Object args[]) throws org.xml.sax.SAXException { String formattedMsg = XSLMessages.createWarning(msg, args); SAXSourceLocator locator = getLocator(); ErrorListener handler = m_stylesheetProcessor.getErrorListener(); try { if (null != handler) handler.warning(new TransformerException(formattedMsg, locator)); } catch (TransformerException te) { throw new org.xml.sax.SAXException(te); } }
/** * Report a fatal XSLT processing error. * * @param e The error information encoded as an exception. * * @throws org.xml.sax.SAXException that wraps a * {@link javax.xml.transform.TransformerException} if the current * {@link javax.xml.transform.ErrorListener#fatalError} * method chooses to flag this condition as an error. */ public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException { String formattedMsg = e.getMessage(); SAXSourceLocator locator = getLocator(); ErrorListener handler = m_stylesheetProcessor.getErrorListener(); try { handler.fatalError(new TransformerException(formattedMsg, locator)); } catch (TransformerException te) { throw new org.xml.sax.SAXException(te); } }
return processFromNode(node, baseID); else String messageStr = XSLMessages.createMessage( XSLTErrorResources.ER_ILLEGAL_DOMSOURCE_INPUT, null); TemplatesHandler builder = newTemplatesHandler(); builder.setSystemId(baseID); throw new org.xml.sax.SAXException(ex); throw new org.xml.sax.SAXException(ex1.toString()); m_errorListener.fatalError(new TransformerException(se)); throw new TransformerConfigurationException(se.getMessage(), se); m_errorListener.fatalError(new TransformerException(e)); return null;