Package org.apache.jasper.xmlparser
Class ParserUtils
- java.lang.Object
-
- org.apache.jasper.xmlparser.ParserUtils
-
public class ParserUtils extends java.lang.Object
XML parsing utilities for processing web application deployment descriptor and tag library descriptor files. FIXME - make these use a separate class loader for the parser to be used.- Version:
- $Revision: 1.11 $ $Date: 2007/05/05 05:32:59 $
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String[]
CACHED_DTD_PUBLIC_IDS
List of the Public IDs that we cache, and their associated location.(package private) static java.lang.String[]
CACHED_DTD_RESOURCE_PATHS
(package private) static java.lang.String[]
CACHED_SCHEMA_RESOURCE_PATHS
private static java.lang.String[]
DEFAULT_DTD_RESOURCE_PATHS
private static java.lang.String[]
DEFAULT_SCHEMA_RESOURCE_PATHS
(package private) static java.lang.String
dtdResourcePrefix
(package private) static org.xml.sax.EntityResolver
entityResolver
An entity resolver for use when parsing XML documents.private static org.xml.sax.ErrorHandler
errorHandler
An error handler for use when parsing XML documents.(package private) static boolean
isDtdResourcePrefixFileUrl
(package private) static boolean
isSchemaResourcePrefixFileUrl
(package private) static java.util.logging.Logger
log
private static java.lang.String
SCHEMA_LOCATION_ATTR
private static java.util.HashMap<java.lang.String,javax.xml.validation.Schema>
schemaCache
(package private) static java.lang.String
schemaResourcePrefix
-
Constructor Summary
Constructors Constructor Description ParserUtils()
ParserUtils(boolean blockExternal)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TreeNode
convert(TreeNode parent, org.w3c.dom.Node node)
Create and return a TreeNode that corresponds to the specified Node, including processing all of the attributes and children nodes.private static javax.xml.validation.Schema
getSchema(java.lang.String schemaPublicId)
private static javax.xml.validation.Schema
getSchema(org.w3c.dom.Document document)
TreeNode
parseXMLDocument(java.lang.String uri, java.io.InputStream is)
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.TreeNode
parseXMLDocument(java.lang.String uri, java.io.InputStream is, boolean validate)
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.TreeNode
parseXMLDocument(java.lang.String uri, org.xml.sax.InputSource is)
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.TreeNode
parseXMLDocument(java.lang.String uri, org.xml.sax.InputSource is, boolean validate)
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.static void
setDtdResourcePrefix(java.lang.String prefix)
Sets the path prefix URL for .dtd resourcesstatic void
setEntityResolver(org.xml.sax.EntityResolver er)
static void
setSchemaResourcePrefix(java.lang.String prefix)
Sets the path prefix URL for .xsd resourcesprivate static java.lang.String
uencode(java.lang.String prefix)
-
-
-
Field Detail
-
log
static java.util.logging.Logger log
-
errorHandler
private static org.xml.sax.ErrorHandler errorHandler
An error handler for use when parsing XML documents.
-
entityResolver
static org.xml.sax.EntityResolver entityResolver
An entity resolver for use when parsing XML documents.
-
schemaResourcePrefix
static java.lang.String schemaResourcePrefix
-
dtdResourcePrefix
static java.lang.String dtdResourcePrefix
-
isDtdResourcePrefixFileUrl
static boolean isDtdResourcePrefixFileUrl
-
isSchemaResourcePrefixFileUrl
static boolean isSchemaResourcePrefixFileUrl
-
SCHEMA_LOCATION_ATTR
private static final java.lang.String SCHEMA_LOCATION_ATTR
- See Also:
- Constant Field Values
-
schemaCache
private static java.util.HashMap<java.lang.String,javax.xml.validation.Schema> schemaCache
-
CACHED_DTD_PUBLIC_IDS
static final java.lang.String[] CACHED_DTD_PUBLIC_IDS
List of the Public IDs that we cache, and their associated location. This is used by an EntityResolver to return the location of the cached copy of a DTD.
-
DEFAULT_DTD_RESOURCE_PATHS
private static final java.lang.String[] DEFAULT_DTD_RESOURCE_PATHS
-
CACHED_DTD_RESOURCE_PATHS
static final java.lang.String[] CACHED_DTD_RESOURCE_PATHS
-
DEFAULT_SCHEMA_RESOURCE_PATHS
private static final java.lang.String[] DEFAULT_SCHEMA_RESOURCE_PATHS
-
CACHED_SCHEMA_RESOURCE_PATHS
static final java.lang.String[] CACHED_SCHEMA_RESOURCE_PATHS
-
-
Method Detail
-
setEntityResolver
public static void setEntityResolver(org.xml.sax.EntityResolver er)
-
setSchemaResourcePrefix
public static void setSchemaResourcePrefix(java.lang.String prefix)
Sets the path prefix URL for .xsd resources
-
setDtdResourcePrefix
public static void setDtdResourcePrefix(java.lang.String prefix)
Sets the path prefix URL for .dtd resources
-
uencode
private static java.lang.String uencode(java.lang.String prefix)
-
parseXMLDocument
public TreeNode parseXMLDocument(java.lang.String uri, org.xml.sax.InputSource is) throws JasperException
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.- Parameters:
uri
- URI of the XML document being parsedis
- Input source containing the deployment descriptor- Throws:
JasperException
- if an I/O or parsing error has occurred
-
parseXMLDocument
public TreeNode parseXMLDocument(java.lang.String uri, org.xml.sax.InputSource is, boolean validate) throws JasperException
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.- Parameters:
uri
- URI of the XML document being parsedis
- Input source containing the deployment descriptorvalidate
- true if the XML document needs to be validated against its DTD or schema, false otherwise- Throws:
JasperException
- if an I/O or parsing error has occurred
-
parseXMLDocument
public TreeNode parseXMLDocument(java.lang.String uri, java.io.InputStream is) throws JasperException
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.- Parameters:
uri
- URI of the XML document being parsedis
- Input stream containing the deployment descriptor- Throws:
JasperException
- if an I/O or parsing error has occurred
-
parseXMLDocument
public TreeNode parseXMLDocument(java.lang.String uri, java.io.InputStream is, boolean validate) throws JasperException
Parse the specified XML document, and return aTreeNode
that corresponds to the root node of the document tree.- Parameters:
uri
- URI of the XML document being parsedis
- Input stream containing the deployment descriptorvalidate
- true if the XML document needs to be validated against its DTD or schema, false otherwise- Throws:
JasperException
- if an I/O or parsing error has occurred
-
convert
protected TreeNode convert(TreeNode parent, org.w3c.dom.Node node)
Create and return a TreeNode that corresponds to the specified Node, including processing all of the attributes and children nodes.- Parameters:
parent
- The parent TreeNode (if any) for the new TreeNodenode
- The XML document Node to be converted
-
getSchema
private static javax.xml.validation.Schema getSchema(org.w3c.dom.Document document) throws org.xml.sax.SAXException, JasperException
- Throws:
org.xml.sax.SAXException
JasperException
-
getSchema
private static javax.xml.validation.Schema getSchema(java.lang.String schemaPublicId) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
-