feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,221 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* Specifies values related to XPath Axes.
* <p>The ancestor, descendant, following, preceding and self axes partition a
* document (ignoring attribute and namespace nodes): they do not overlap
* and together they contain all the nodes in the document.</p>
*
*/
public final class Axis
{
/**
* The ancestor axis contains the ancestors of the context node;
* the ancestors of the context node consist of the parent of context
* node and the parent's parent and so on; thus, the ancestor axis will
* always include the root node, unless the context node is the root node.
*/
public static final int ANCESTOR = 0;
/**
* the ancestor-or-self axis contains the context node and the ancestors of
* the context node; thus, the ancestor axis will always include the
* root node.
*/
public static final int ANCESTORORSELF = 1;
/**
* the attribute axis contains the attributes of the context node; the axis
* will be empty unless the context node is an element.
*/
public static final int ATTRIBUTE = 2;
/** The child axis contains the children of the context node. */
public static final int CHILD = 3;
/**
* The descendant axis contains the descendants of the context node;
* a descendant is a child or a child of a child and so on; thus the
* descendant axis never contains attribute or namespace nodes.
*/
public static final int DESCENDANT = 4;
/**
* The descendant-or-self axis contains the context node and the
* descendants of the context node.
*/
public static final int DESCENDANTORSELF = 5;
/**
* the following axis contains all nodes in the same document as the
* context node that are after the context node in document order, excluding
* any descendants and excluding attribute nodes and namespace nodes.
*/
public static final int FOLLOWING = 6;
/**
* The following-sibling axis contains all the following siblings of the
* context node; if the context node is an attribute node or namespace node,
* the following-sibling axis is empty.
*/
public static final int FOLLOWINGSIBLING = 7;
/**
* The namespace axis contains the namespace nodes of the context node; the
* axis will be empty unless the context node is an element.
*/
public static final int NAMESPACEDECLS = 8;
/**
* The namespace axis contains the namespace nodes of the context node; the
* axis will be empty unless the context node is an element.
*/
public static final int NAMESPACE = 9;
/**
* The parent axis contains the parent of the context node,
* if there is one.
*/
public static final int PARENT = 10;
/**
* The preceding axis contains all nodes in the same document as the context
* node that are before the context node in document order, excluding any
* ancestors and excluding attribute nodes and namespace nodes
*/
public static final int PRECEDING = 11;
/**
* The preceding-sibling axis contains all the preceding siblings of the
* context node; if the context node is an attribute node or namespace node,
* the preceding-sibling axis is empty.
*/
public static final int PRECEDINGSIBLING = 12;
/** The self axis contains just the context node itself. */
public static final int SELF = 13;
/**
* A non-xpath axis, traversing the subtree including the subtree
* root, descendants, attributes, and namespace node decls.
*/
public static final int ALLFROMNODE = 14;
/**
* A non-xpath axis, traversing the the preceding and the ancestor nodes,
* needed for inverseing select patterns to match patterns.
*/
public static final int PRECEDINGANDANCESTOR = 15;
// ===========================================
// All axis past this are absolute.
/**
* A non-xpath axis, returns all nodes in the tree from and including the
* root.
*/
public static final int ALL = 16;
/**
* A non-xpath axis, returns all nodes that aren't namespaces or attributes,
* from and including the root.
*/
public static final int DESCENDANTSFROMROOT = 17;
/**
* A non-xpath axis, returns all nodes that aren't namespaces or attributes,
* from and including the root.
*/
public static final int DESCENDANTSORSELFFROMROOT = 18;
/**
* A non-xpath axis, returns root only.
*/
public static final int ROOT = 19;
/**
* A non-xpath axis, for functions.
*/
public static final int FILTEREDLIST = 20;
/**
* A table to identify whether an axis is a reverse axis;
*/
private static final boolean[] isReverse = {
true, // ancestor
true, // ancestor-or-self
false, // attribute
false, // child
false, // descendant
false, // descendant-or-self
false, // following
false, // following-sibling
false, // namespace
false, // namespace-declarations
false, // parent (one node, has no order)
true, // preceding
true, // preceding-sibling
false // self (one node, has no order)
};
/** The names of the axes for diagnostic purposes. */
private static final String[] names =
{
"ancestor", // 0
"ancestor-or-self", // 1
"attribute", // 2
"child", // 3
"descendant", // 4
"descendant-or-self", // 5
"following", // 6
"following-sibling", // 7
"namespace-decls", // 8
"namespace", // 9
"parent", // 10
"preceding", // 11
"preceding-sibling", // 12
"self", // 13
"all-from-node", // 14
"preceding-and-ancestor", // 15
"all", // 16
"descendants-from-root", // 17
"descendants-or-self-from-root", // 18
"root", // 19
"filtered-list" // 20
};
public static boolean isReverse(int axis){
return isReverse[axis];
}
public static String getNames(int index){
return names[index];
}
public static int getNamesLength(){
return names.length;
}
}

View File

@@ -0,0 +1,968 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
import javax.xml.transform.SourceLocator;
import com.sun.org.apache.xml.internal.utils.XMLString;
/**
* <code>DTM</code> is an XML document model expressed as a table
* rather than an object tree. It attempts to provide an interface to
* a parse tree that has very little object creation. (DTM
* implementations may also support incremental construction of the
* model, but that's hidden from the DTM API.)
*
* <p>Nodes in the DTM are identified by integer "handles". A handle must
* be unique within a process, and carries both node identification and
* document identification. It must be possible to compare two handles
* (and thus their nodes) for identity with "==".</p>
*
* <p>Namespace URLs, local-names, and expanded-names can all be
* represented by and tested as integer ID values. An expanded name
* represents (and may or may not directly contain) a combination of
* the URL ID, and the local-name ID. Note that the namespace URL id
* can be 0, which should have the meaning that the namespace is null.
* For consistancy, zero should not be used for a local-name index. </p>
*
* <p>Text content of a node is represented by an index and length,
* permitting efficient storage such as a shared FastStringBuffer.</p>
*
* <p>The model of the tree, as well as the general navigation model,
* is that of XPath 1.0, for the moment. The model will eventually be
* adapted to match the XPath 2.0 data model, XML Schema, and
* InfoSet.</p>
*
* <p>DTM does _not_ directly support the W3C's Document Object
* Model. However, it attempts to come close enough that an
* implementation of DTM can be created that wraps a DOM and vice
* versa.</p>
*
* <p><strong>Please Note:</strong> The DTM API is still
* <strong>Subject To Change.</strong> This wouldn't affect most
* users, but might require updating some extensions.</p>
*
* <p> The largest change being contemplated is a reconsideration of
* the Node Handle representation. We are still not entirely sure
* that an integer packed with two numeric subfields is really the
* best solution. It has been suggested that we move up to a Long, to
* permit more nodes per document without having to reduce the number
* of slots in the DTMManager. There's even been a proposal that we
* replace these integers with "cursor" objects containing the
* internal node id and a pointer to the actual DTM object; this might
* reduce the need to continuously consult the DTMManager to retrieve
* the latter, and might provide a useful "hook" back into normal Java
* heap management. But changing this datatype would have huge impact
* on Xalan's internals -- especially given Java's lack of C-style
* typedefs -- so we won't cut over unless we're convinced the new
* solution really would be an improvement!</p>
* */
public interface DTM
{
/**
* Null node handles are represented by this value.
*/
public static final int NULL = -1;
// These nodeType mnemonics and values are deliberately the same as those
// used by the DOM, for convenient mapping
//
// %REVIEW% Should we actually define these as initialized to,
// eg. org.w3c.dom.Document.ELEMENT_NODE?
/**
* The node is a <code>Root</code>.
*/
public static final short ROOT_NODE = 0;
/**
* The node is an <code>Element</code>.
*/
public static final short ELEMENT_NODE = 1;
/**
* The node is an <code>Attr</code>.
*/
public static final short ATTRIBUTE_NODE = 2;
/**
* The node is a <code>Text</code> node.
*/
public static final short TEXT_NODE = 3;
/**
* The node is a <code>CDATASection</code>.
*/
public static final short CDATA_SECTION_NODE = 4;
/**
* The node is an <code>EntityReference</code>.
*/
public static final short ENTITY_REFERENCE_NODE = 5;
/**
* The node is an <code>Entity</code>.
*/
public static final short ENTITY_NODE = 6;
/**
* The node is a <code>ProcessingInstruction</code>.
*/
public static final short PROCESSING_INSTRUCTION_NODE = 7;
/**
* The node is a <code>Comment</code>.
*/
public static final short COMMENT_NODE = 8;
/**
* The node is a <code>Document</code>.
*/
public static final short DOCUMENT_NODE = 9;
/**
* The node is a <code>DocumentType</code>.
*/
public static final short DOCUMENT_TYPE_NODE = 10;
/**
* The node is a <code>DocumentFragment</code>.
*/
public static final short DOCUMENT_FRAGMENT_NODE = 11;
/**
* The node is a <code>Notation</code>.
*/
public static final short NOTATION_NODE = 12;
/**
* The node is a <code>namespace node</code>. Note that this is not
* currently a node type defined by the DOM API.
*/
public static final short NAMESPACE_NODE = 13;
/**
* The number of valid nodetypes.
*/
public static final short NTYPES = 14;
// ========= DTM Implementation Control Functions. ==============
// %TBD% RETIRED -- do via setFeature if needed. Remove from impls.
// public void setParseBlockSize(int blockSizeSuggestion);
/**
* Set an implementation dependent feature.
* <p>
* %REVIEW% Do we really expect to set features on DTMs?
*
* @param featureId A feature URL.
* @param state true if this feature should be on, false otherwise.
*/
public void setFeature(String featureId, boolean state);
/**
* Set a run time property for this DTM instance.
*
* @param property a <code>String</code> value
* @param value an <code>Object</code> value
*/
public void setProperty(String property, Object value);
// ========= Document Navigation Functions =========
/**
* This returns a stateless "traverser", that can navigate over an
* XPath axis, though not in document order.
*
* @param axis One of Axes.ANCESTORORSELF, etc.
*
* @return A DTMAxisIterator, or null if the givin axis isn't supported.
*/
public DTMAxisTraverser getAxisTraverser(final int axis);
/**
* This is a shortcut to the iterators that implement
* XPath axes.
* Returns a bare-bones iterator that must be initialized
* with a start node (using iterator.setStartNode()).
*
* @param axis One of Axes.ANCESTORORSELF, etc.
*
* @return A DTMAxisIterator, or null if the givin axis isn't supported.
*/
public DTMAxisIterator getAxisIterator(final int axis);
/**
* Get an iterator that can navigate over an XPath Axis, predicated by
* the extended type ID.
*
* @param axis
* @param type An extended type ID.
*
* @return A DTMAxisIterator, or null if the givin axis isn't supported.
*/
public DTMAxisIterator getTypedAxisIterator(final int axis, final int type);
/**
* Given a node handle, test if it has child nodes.
* <p> %REVIEW% This is obviously useful at the DOM layer, where it
* would permit testing this without having to create a proxy
* node. It's less useful in the DTM API, where
* (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
* almost as self-evident. But it's a convenience, and eases porting
* of DOM code to DTM. </p>
*
* @param nodeHandle int Handle of the node.
* @return int true if the given node has child nodes.
*/
public boolean hasChildNodes(int nodeHandle);
/**
* Given a node handle, get the handle of the node's first child.
*
* @param nodeHandle int Handle of the node.
* @return int DTM node-number of first child,
* or DTM.NULL to indicate none exists.
*/
public int getFirstChild(int nodeHandle);
/**
* Given a node handle, get the handle of the node's last child.
*
* @param nodeHandle int Handle of the node.
* @return int Node-number of last child,
* or DTM.NULL to indicate none exists.
*/
public int getLastChild(int nodeHandle);
/**
* Retrieves an attribute node by local name and namespace URI
*
* %TBD% Note that we currently have no way to support
* the DOM's old getAttribute() call, which accesses only the qname.
*
* @param elementHandle Handle of the node upon which to look up this attribute.
* @param namespaceURI The namespace URI of the attribute to
* retrieve, or null.
* @param name The local name of the attribute to
* retrieve.
* @return The attribute node handle with the specified name (
* <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
* attribute.
*/
public int getAttributeNode(int elementHandle, String namespaceURI,
String name);
/**
* Given a node handle, get the index of the node's first attribute.
*
* @param nodeHandle int Handle of the node.
* @return Handle of first attribute, or DTM.NULL to indicate none exists.
*/
public int getFirstAttribute(int nodeHandle);
/**
* Given a node handle, get the index of the node's first namespace node.
*
* @param nodeHandle handle to node, which should probably be an element
* node, but need not be.
*
* @param inScope true if all namespaces in scope should be
* returned, false if only the node's own
* namespace declarations should be returned.
* @return handle of first namespace,
* or DTM.NULL to indicate none exists.
*/
public int getFirstNamespaceNode(int nodeHandle, boolean inScope);
/**
* Given a node handle, advance to its next sibling.
* @param nodeHandle int Handle of the node.
* @return int Node-number of next sibling,
* or DTM.NULL to indicate none exists.
*/
public int getNextSibling(int nodeHandle);
/**
* Given a node handle, find its preceeding sibling.
* WARNING: DTM implementations may be asymmetric; in some,
* this operation has been resolved by search, and is relatively expensive.
*
* @param nodeHandle the id of the node.
* @return int Node-number of the previous sib,
* or DTM.NULL to indicate none exists.
*/
public int getPreviousSibling(int nodeHandle);
/**
* Given a node handle, advance to the next attribute. If an
* element, we advance to its first attribute; if an attr, we advance to
* the next attr of the same element.
*
* @param nodeHandle int Handle of the node.
* @return int DTM node-number of the resolved attr,
* or DTM.NULL to indicate none exists.
*/
public int getNextAttribute(int nodeHandle);
/**
* Given a namespace handle, advance to the next namespace in the same scope
* (local or local-plus-inherited, as selected by getFirstNamespaceNode)
*
* @param baseHandle handle to original node from where the first child
* was relative to (needed to return nodes in document order).
* @param namespaceHandle handle to node which must be of type
* NAMESPACE_NODE.
* NEEDSDOC @param inScope
* @return handle of next namespace,
* or DTM.NULL to indicate none exists.
*/
public int getNextNamespaceNode(int baseHandle, int namespaceHandle,
boolean inScope);
/**
* Given a node handle, find its parent node.
*
* @param nodeHandle the id of the node.
* @return int Node handle of parent,
* or DTM.NULL to indicate none exists.
*/
public int getParent(int nodeHandle);
/**
* Given a DTM which contains only a single document,
* find the Node Handle of the Document node. Note
* that if the DTM is configured so it can contain multiple
* documents, this call will return the Document currently
* under construction -- but may return null if it's between
* documents. Generally, you should use getOwnerDocument(nodeHandle)
* or getDocumentRoot(nodeHandle) instead.
*
* @return int Node handle of document, or DTM.NULL if a shared DTM
* can not tell us which Document is currently active.
*/
public int getDocument();
/**
* Given a node handle, find the owning document node. This version mimics
* the behavior of the DOM call by the same name.
*
* @param nodeHandle the id of the node.
* @return int Node handle of owning document, or DTM.NULL if the node was
* a Document.
* @see #getDocumentRoot(int nodeHandle)
*/
public int getOwnerDocument(int nodeHandle);
/**
* Given a node handle, find the owning document node.
*
* @param nodeHandle the id of the node.
* @return int Node handle of owning document, or the node itself if it was
* a Document. (Note difference from DOM, where getOwnerDocument returns
* null for the Document node.)
* @see #getOwnerDocument(int nodeHandle)
*/
public int getDocumentRoot(int nodeHandle);
/**
* Get the string-value of a node as a String object
* (see http://www.w3.org/TR/xpath#data-model
* for the definition of a node's string-value).
*
* @param nodeHandle The node ID.
*
* @return A string object that represents the string-value of the given node.
*/
public XMLString getStringValue(int nodeHandle);
/**
* Get number of character array chunks in
* the string-value of a node.
* (see http://www.w3.org/TR/xpath#data-model
* for the definition of a node's string-value).
* Note that a single text node may have multiple text chunks.
*
* @param nodeHandle The node ID.
*
* @return number of character array chunks in
* the string-value of a node.
*/
public int getStringValueChunkCount(int nodeHandle);
/**
* Get a character array chunk in the string-value of a node.
* (see http://www.w3.org/TR/xpath#data-model
* for the definition of a node's string-value).
* Note that a single text node may have multiple text chunks.
*
* @param nodeHandle The node ID.
* @param chunkIndex Which chunk to get.
* @param startAndLen A two-integer array which, upon return, WILL
* BE FILLED with values representing the chunk's start position
* within the returned character buffer and the length of the chunk.
* @return The character array buffer within which the chunk occurs,
* setting startAndLen's contents as a side-effect.
*/
public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
int[] startAndLen);
/**
* Given a node handle, return an ID that represents the node's expanded name.
*
* @param nodeHandle The handle to the node in question.
*
* @return the expanded-name id of the node.
*/
public int getExpandedTypeID(int nodeHandle);
/**
* Given an expanded name, return an ID. If the expanded-name does not
* exist in the internal tables, the entry will be created, and the ID will
* be returned. Any additional nodes that are created that have this
* expanded name will use this ID.
*
* NEEDSDOC @param namespace
* NEEDSDOC @param localName
* NEEDSDOC @param type
*
* @return the expanded-name id of the node.
*/
public int getExpandedTypeID(String namespace, String localName, int type);
/**
* Given an expanded-name ID, return the local name part.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return String Local name of this node.
*/
public String getLocalNameFromExpandedNameID(int ExpandedNameID);
/**
* Given an expanded-name ID, return the namespace URI part.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return String URI value of this node's namespace, or null if no
* namespace was resolved.
*/
public String getNamespaceFromExpandedNameID(int ExpandedNameID);
/**
* Given a node handle, return its DOM-style node name. This will
* include names such as #text or #document.
*
* @param nodeHandle the id of the node.
* @return String Name of this node, which may be an empty string.
* %REVIEW% Document when empty string is possible...
*/
public String getNodeName(int nodeHandle);
/**
* Given a node handle, return the XPath node name. This should be
* the name as described by the XPath data model, NOT the DOM-style
* name.
*
* @param nodeHandle the id of the node.
* @return String Name of this node.
*/
public String getNodeNameX(int nodeHandle);
/**
* Given a node handle, return its DOM-style localname.
* (As defined in Namespaces, this is the portion of the name after the
* prefix, if present, or the whole node name if no prefix exists)
*
* @param nodeHandle the id of the node.
* @return String Local name of this node.
*/
public String getLocalName(int nodeHandle);
/**
* Given a namespace handle, return the prefix that the namespace decl is
* mapping.
* Given a node handle, return the prefix used to map to the namespace.
* (As defined in Namespaces, this is the portion of the name before any
* colon character).
*
* <p> %REVIEW% Are you sure you want "" for no prefix? </p>
*
* @param nodeHandle the id of the node.
* @return String prefix of this node's name, or "" if no explicit
* namespace prefix was given.
*/
public String getPrefix(int nodeHandle);
/**
* Given a node handle, return its DOM-style namespace URI
* (As defined in Namespaces, this is the declared URI which this node's
* prefix -- or default in lieu thereof -- was mapped to.)
* @param nodeHandle the id of the node.
* @return String URI value of this node's namespace, or null if no
* namespace was resolved.
*/
public String getNamespaceURI(int nodeHandle);
/**
* Given a node handle, return its node value. This is mostly
* as defined by the DOM, but may ignore some conveniences.
* <p>
* @param nodeHandle The node id.
* @return String Value of this node, or null if not
* meaningful for this node type.
*/
public String getNodeValue(int nodeHandle);
/**
* Given a node handle, return its DOM-style node type.
*
* <p>%REVIEW% Generally, returning short is false economy. Return int?</p>
*
* @param nodeHandle The node id.
* @return int Node type, as per the DOM's Node._NODE constants.
*/
public short getNodeType(int nodeHandle);
/**
* Get the depth level of this node in the tree (equals 1 for
* a parentless node).
*
* @param nodeHandle The node id.
* @return the number of ancestors, plus one
* @xsl.usage internal
*/
public short getLevel(int nodeHandle);
// ============== Document query functions ==============
/**
* Tests whether DTM DOM implementation implements a specific feature and
* that feature is supported by this node.
* @param feature The name of the feature to test.
* @param version This is the version number of the feature to test.
* If the version is not
* specified, supporting any version of the feature will cause the
* method to return <code>true</code>.
* @return Returns <code>true</code> if the specified feature is
* supported on this node, <code>false</code> otherwise.
*/
public boolean isSupported(String feature, String version);
/**
* Return the base URI of the document entity. If it is not known
* (because the document was parsed from a socket connection or from
* standard input, for example), the value of this property is unknown.
*
* @return the document base URI String object or null if unknown.
*/
public String getDocumentBaseURI();
/**
* Set the base URI of the document entity.
*
* @param baseURI the document base URI String object or null if unknown.
*/
public void setDocumentBaseURI(String baseURI);
/**
* Return the system identifier of the document entity. If
* it is not known, the value of this property is null.
*
* @param nodeHandle The node id, which can be any valid node handle.
* @return the system identifier String object or null if unknown.
*/
public String getDocumentSystemIdentifier(int nodeHandle);
/**
* Return the name of the character encoding scheme
* in which the document entity is expressed.
*
* @param nodeHandle The node id, which can be any valid node handle.
* @return the document encoding String object.
*/
public String getDocumentEncoding(int nodeHandle);
/**
* Return an indication of the standalone status of the document,
* either "yes" or "no". This property is derived from the optional
* standalone document declaration in the XML declaration at the
* beginning of the document entity, and has no value if there is no
* standalone document declaration.
*
* @param nodeHandle The node id, which can be any valid node handle.
* @return the document standalone String object, either "yes", "no", or null.
*/
public String getDocumentStandalone(int nodeHandle);
/**
* Return a string representing the XML version of the document. This
* property is derived from the XML declaration optionally present at the
* beginning of the document entity, and has no value if there is no XML
* declaration.
*
* @param documentHandle the document handle
* @return the document version String object
*/
public String getDocumentVersion(int documentHandle);
/**
* Return an indication of
* whether the processor has read the complete DTD. Its value is a
* boolean. If it is false, then certain properties (indicated in their
* descriptions below) may be unknown. If it is true, those properties
* are never unknown.
*
* @return <code>true</code> if all declarations were processed;
* <code>false</code> otherwise.
*/
public boolean getDocumentAllDeclarationsProcessed();
/**
* A document type declaration information item has the following properties:
*
* 1. [system identifier] The system identifier of the external subset, if
* it exists. Otherwise this property has no value.
*
* @return the system identifier String object, or null if there is none.
*/
public String getDocumentTypeDeclarationSystemIdentifier();
/**
* Return the public identifier of the external subset,
* normalized as described in 4.2.2 External Entities [XML]. If there is
* no external subset or if it has no public identifier, this property
* has no value.
*
* @return the public identifier String object, or null if there is none.
*/
public String getDocumentTypeDeclarationPublicIdentifier();
/**
* Returns the <code>Element</code> whose <code>ID</code> is given by
* <code>elementId</code>. If no such element exists, returns
* <code>DTM.NULL</code>. Behavior is not defined if more than one element
* has this <code>ID</code>. Attributes (including those
* with the name "ID") are not of type ID unless so defined by DTD/Schema
* information available to the DTM implementation.
* Implementations that do not know whether attributes are of type ID or
* not are expected to return <code>DTM.NULL</code>.
*
* <p>%REVIEW% Presumably IDs are still scoped to a single document,
* and this operation searches only within a single document, right?
* Wouldn't want collisions between DTMs in the same process.</p>
*
* @param elementId The unique <code>id</code> value for an element.
* @return The handle of the matching element.
*/
public int getElementById(String elementId);
/**
* The getUnparsedEntityURI function returns the URI of the unparsed
* entity with the specified name in the same document as the context
* node (see [3.3 Unparsed Entities]). It returns the empty string if
* there is no such entity.
* <p>
* XML processors may choose to use the System Identifier (if one
* is provided) to resolve the entity, rather than the URI in the
* Public Identifier. The details are dependent on the processor, and
* we would have to support some form of plug-in resolver to handle
* this properly. Currently, we simply return the System Identifier if
* present, and hope that it a usable URI or that our caller can
* map it to one.
* %REVIEW% Resolve Public Identifiers... or consider changing function name.
* <p>
* If we find a relative URI
* reference, XML expects it to be resolved in terms of the base URI
* of the document. The DOM doesn't do that for us, and it isn't
* entirely clear whether that should be done here; currently that's
* pushed up to a higher level of our application. (Note that DOM Level
* 1 didn't store the document's base URI.)
* %REVIEW% Consider resolving Relative URIs.
* <p>
* (The DOM's statement that "An XML processor may choose to
* completely expand entities before the structure model is passed
* to the DOM" refers only to parsed entities, not unparsed, and hence
* doesn't affect this function.)
*
* @param name A string containing the Entity Name of the unparsed
* entity.
*
* @return String containing the URI of the Unparsed Entity, or an
* empty string if no such entity exists.
*/
public String getUnparsedEntityURI(String name);
// ============== Boolean methods ================
/**
* Return true if the xsl:strip-space or xsl:preserve-space was processed
* during construction of the document contained in this DTM.
*
* NEEDSDOC ($objectName$) @return
*/
public boolean supportsPreStripping();
/**
* Figure out whether nodeHandle2 should be considered as being later
* in the document than nodeHandle1, in Document Order as defined
* by the XPath model. This may not agree with the ordering defined
* by other XML applications.
* <p>
* There are some cases where ordering isn't defined, and neither are
* the results of this function -- though we'll generally return true.
* <p>
* %REVIEW% Make sure this does the right thing with attribute nodes!!!
* <p>
* %REVIEW% Consider renaming for clarity. Perhaps isDocumentOrder(a,b)?
*
* @param firstNodeHandle DOM Node to perform position comparison on.
* @param secondNodeHandle DOM Node to perform position comparison on.
*
* @return false if secondNode comes before firstNode, otherwise return true.
* You can think of this as
* <code>(firstNode.documentOrderPosition &lt;= secondNode.documentOrderPosition)</code>.
*/
public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle);
/**
* 2. [element content whitespace] A boolean indicating whether a
* text node represents white space appearing within element content
* (see [XML], 2.10 "White Space Handling"). Note that validating
* XML processors are required by XML 1.0 to provide this
* information... but that DOM Level 2 did not support it, since it
* depends on knowledge of the DTD which DOM2 could not guarantee
* would be available.
* <p>
* If there is no declaration for the containing element, an XML
* processor must assume that the whitespace could be meaningful and
* return false. If no declaration has been read, but the [all
* declarations processed] property of the document information item
* is false (so there may be an unread declaration), then the value
* of this property is indeterminate for white space characters and
* should probably be reported as false. It is always false for text
* nodes that contain anything other than (or in addition to) white
* space.
* <p>
* Note too that it always returns false for non-Text nodes.
* <p>
* %REVIEW% Joe wants to rename this isWhitespaceInElementContent() for clarity
*
* @param nodeHandle the node ID.
* @return <code>true</code> if the node definitely represents whitespace in
* element content; <code>false</code> otherwise.
*/
public boolean isCharacterElementContentWhitespace(int nodeHandle);
/**
* 10. [all declarations processed] This property is not strictly speaking
* part of the infoset of the document. Rather it is an indication of
* whether the processor has read the complete DTD. Its value is a
* boolean. If it is false, then certain properties (indicated in their
* descriptions below) may be unknown. If it is true, those properties
* are never unknown.
*
* @param documentHandle A node handle that must identify a document.
* @return <code>true</code> if all declarations were processed;
* <code>false</code> otherwise.
*/
public boolean isDocumentAllDeclarationsProcessed(int documentHandle);
/**
* 5. [specified] A flag indicating whether this attribute was actually
* specified in the start-tag of its element, or was defaulted from the
* DTD (or schema).
*
* @param attributeHandle The attribute handle
* @return <code>true</code> if the attribute was specified;
* <code>false</code> if it was defaulted or the handle doesn't
* refer to an attribute node.
*/
public boolean isAttributeSpecified(int attributeHandle);
// ========== Direct SAX Dispatch, for optimization purposes ========
/**
* Directly call the
* characters method on the passed ContentHandler for the
* string-value of the given node (see http://www.w3.org/TR/xpath#data-model
* for the definition of a node's string-value). Multiple calls to the
* ContentHandler's characters methods may well occur for a single call to
* this method.
*
* @param nodeHandle The node ID.
* @param ch A non-null reference to a ContentHandler.
* @param normalize true if the content should be normalized according to
* the rules for the XPath
* <a href="http://www.w3.org/TR/xpath#function-normalize-space">normalize-space</a>
* function.
*
* @throws org.xml.sax.SAXException
*/
public void dispatchCharactersEvents(
int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
throws org.xml.sax.SAXException;
/**
* Directly create SAX parser events representing the XML content of
* a DTM subtree. This is a "serialize" operation.
*
* @param nodeHandle The node ID.
* @param ch A non-null reference to a ContentHandler.
*
* @throws org.xml.sax.SAXException
*/
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
throws org.xml.sax.SAXException;
/**
* Return an DOM node for the given node.
*
* @param nodeHandle The node ID.
*
* @return A node representation of the DTM node.
*/
public org.w3c.dom.Node getNode(int nodeHandle);
// ==== Construction methods (may not be supported by some implementations!) =====
// %REVIEW% What response occurs if not supported?
/**
* @return true iff we're building this model incrementally (eg
* we're partnered with a CoroutineParser) and thus require that the
* transformation and the parse run simultaneously. Guidance to the
* DTMManager.
*/
public boolean needsTwoThreads();
// %REVIEW% Do these appends make any sense, should we support a
// wider set of methods (like the "append" methods in the
// current DTMDocumentImpl draft), or should we just support SAX
// listener interfaces? Should it be a separate interface to
// make that distinction explicit?
/**
* Return this DTM's content handler, if it has one.
*
* @return null if this model doesn't respond to SAX events.
*/
public org.xml.sax.ContentHandler getContentHandler();
/**
* Return this DTM's lexical handler, if it has one.
*
* %REVIEW% Should this return null if constrution already done/begun?
*
* @return null if this model doesn't respond to lexical SAX events.
*/
public org.xml.sax.ext.LexicalHandler getLexicalHandler();
/**
* Return this DTM's EntityResolver, if it has one.
*
* @return null if this model doesn't respond to SAX entity ref events.
*/
public org.xml.sax.EntityResolver getEntityResolver();
/**
* Return this DTM's DTDHandler, if it has one.
*
* @return null if this model doesn't respond to SAX dtd events.
*/
public org.xml.sax.DTDHandler getDTDHandler();
/**
* Return this DTM's ErrorHandler, if it has one.
*
* @return null if this model doesn't respond to SAX error events.
*/
public org.xml.sax.ErrorHandler getErrorHandler();
/**
* Return this DTM's DeclHandler, if it has one.
*
* @return null if this model doesn't respond to SAX Decl events.
*/
public org.xml.sax.ext.DeclHandler getDeclHandler();
/**
* Append a child to "the end of the document". Please note that
* the node is always cloned in a base DTM, since our basic behavior
* is immutable so nodes can't be removed from their previous
* location.
*
* <p> %REVIEW% DTM maintains an insertion cursor which
* performs a depth-first tree walk as nodes come in, and this operation
* is really equivalent to:
* insertionCursor.appendChild(document.importNode(newChild)))
* where the insert point is the last element that was appended (or
* the last one popped back to by an end-element operation).</p>
*
* @param newChild Must be a valid new node handle.
* @param clone true if the child should be cloned into the document.
* @param cloneDepth if the clone argument is true, specifies that the
* clone should include all it's children.
*/
public void appendChild(int newChild, boolean clone, boolean cloneDepth);
/**
* Append a text node child that will be constructed from a string,
* to the end of the document. Behavior is otherwise like appendChild().
*
* @param str Non-null reference to a string.
*/
public void appendTextChild(String str);
/**
* Get the location of a node in the source document.
*
* @param node an <code>int</code> value
* @return a <code>SourceLocator</code> value or null if no location
* is available
*/
public SourceLocator getSourceLocatorFor(int node);
/**
* As the DTM is registered with the DTMManager, this method
* will be called. This will give the DTM implementation a
* chance to initialize any subsystems that are required to
* build the DTM
*/
public void documentRegistration();
/**
* As documents are released from the DTMManager, the DTM implementation
* will be notified of the event. This will allow the DTM implementation
* to shutdown any subsystem activity that may of been assoiated with
* the active DTM Implementation.
*/
public void documentRelease();
/**
* Migrate a DTM built with an old DTMManager to a new DTMManager.
* After the migration, the new DTMManager will treat the DTM as
* one that is built by itself.
* This is used to support DTM sharing between multiple transformations.
* @param manager the DTMManager
*/
public void migrateTo(DTMManager manager);
}

View File

@@ -0,0 +1,111 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* This class iterates over a single XPath Axis, and returns node handles.
*/
public interface DTMAxisIterator extends Cloneable
{
/** Specifies the end of the iteration, and is the same as DTM.NULL. */
public static final int END = DTM.NULL;
/**
* Get the next node in the iteration.
*
* @return The next node handle in the iteration, or END.
*/
public int next();
/**
* Resets the iterator to the last start node.
*
* @return A DTMAxisIterator, which may or may not be the same as this
* iterator.
*/
public DTMAxisIterator reset();
/**
* @return the number of nodes in this iterator. This may be an expensive
* operation when called the first time.
*/
public int getLast();
/**
* @return The position of the current node in the set, as defined by XPath.
*/
public int getPosition();
/**
* Remembers the current node for the next call to gotoMark().
*/
public void setMark();
/**
* Restores the current node remembered by setMark().
*/
public void gotoMark();
/**
* Set start to END should 'close' the iterator,
* i.e. subsequent call to next() should return END.
*
* @param node Sets the root of the iteration.
*
* @return A DTMAxisIterator set to the start of the iteration.
*/
public DTMAxisIterator setStartNode(int node);
/**
* Get start to END should 'close' the iterator,
* i.e. subsequent call to next() should return END.
*
* @return The root node of the iteration.
*/
public int getStartNode();
/**
* @return true if this iterator has a reversed axis, else false.
*/
public boolean isReverse();
/**
* @return a deep copy of this iterator. The clone should not be reset
* from its current position.
*/
public DTMAxisIterator cloneIterator();
/**
* Set if restartable.
*/
public void setRestartable(boolean isRestartable);
/**
* Return the node at the given position.
*
* @param position The position
* @return The node at the given position.
*/
public int getNodeByPosition(int position);
}

View File

@@ -0,0 +1,117 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* A class that implements traverses DTMAxisTraverser interface can traverse
* a set of nodes, usually as defined by an XPath axis. It is different from
* an iterator, because it does not need to hold state, and, in fact, must not
* hold any iteration-based state. It is meant to be implemented as an inner
* class of a DTM, and returned by the getAxisTraverser(final int axis)
* function.
*
* <p>A DTMAxisTraverser can probably not traverse a reverse axis in
* document order.</p>
*
* <p>Typical usage:</p>
* <pre><code>
* for(int nodeHandle=myTraverser.first(myContext);
* nodeHandle!=DTM.NULL;
* nodeHandle=myTraverser.next(myContext,nodeHandle))
* { ... processing for node indicated by nodeHandle goes here ... }
* </code></pre>
*
* @author Scott Boag
*/
public abstract class DTMAxisTraverser
{
/**
* By the nature of the stateless traversal, the context node can not be
* returned or the iteration will go into an infinate loop. So to traverse
* an axis, the first function must be used to get the first node.
*
* <p>This method needs to be overloaded only by those axis that process
* the self node. <\p>
*
* @param context The context node of this traversal. This is the point
* that the traversal starts from.
* @return the first node in the traversal.
*/
public int first(int context)
{
return next(context, context);
}
/**
* By the nature of the stateless traversal, the context node can not be
* returned or the iteration will go into an infinate loop. So to traverse
* an axis, the first function must be used to get the first node.
*
* <p>This method needs to be overloaded only by those axis that process
* the self node. <\p>
*
* @param context The context node of this traversal. This is the point
* of origin for the traversal -- its "root node" or starting point.
* @param extendedTypeID The extended type ID that must match.
*
* @return the first node in the traversal.
*/
public int first(int context, int extendedTypeID)
{
return next(context, context, extendedTypeID);
}
/**
* Traverse to the next node after the current node.
*
* @param context The context node of this traversal. This is the point
* of origin for the traversal -- its "root node" or starting point.
* @param current The current node of the traversal. This is the last known
* location in the traversal, typically the node-handle returned by the
* previous traversal step. For the first traversal step, context
* should be set equal to current. Note that in order to test whether
* context is in the set, you must use the first() method instead.
*
* @return the next node in the iteration, or DTM.NULL.
* @see #first(int)
*/
public abstract int next(int context, int current);
/**
* Traverse to the next node after the current node that is matched
* by the extended type ID.
*
* @param context The context node of this traversal. This is the point
* of origin for the traversal -- its "root node" or starting point.
* @param current The current node of the traversal. This is the last known
* location in the traversal, typically the node-handle returned by the
* previous traversal step. For the first traversal step, context
* should be set equal to current. Note that in order to test whether
* context is in the set, you must use the first() method instead.
* @param extendedTypeID The extended type ID that must match.
*
* @return the next node in the iteration, or DTM.NULL.
* @see #first(int,int)
*/
public abstract int next(int context, int current, int extendedTypeID);
}

View File

@@ -0,0 +1,55 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* Simple implementation of DOMException.
*
* %REVIEW% Several classes were implementing this internally;
* it makes more sense to have one shared version.
* @xsl.usage internal
*/
public class DTMDOMException extends org.w3c.dom.DOMException
{
static final long serialVersionUID = 1895654266613192414L;
/**
* Constructs a DOM/DTM exception.
*
* @param code
* @param message
*/
public DTMDOMException(short code, String message)
{
super(code, message);
}
/**
* Constructor DTMDOMException
*
*
* @param code
*/
public DTMDOMException(short code)
{
super(code, "");
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* This class specifies an exceptional condition that occurred
* in the DTM module.
*/
public class DTMException extends RuntimeException {
static final long serialVersionUID = -775576419181334734L;
/**
* Create a new DTMException.
*
* @param message The error or warning message.
*/
public DTMException(String message) {
super(message);
}
/**
* Create a new DTMException wrapping an existing exception.
*
* @param e The exception to be wrapped.
*/
public DTMException(Throwable e) {
super(e);
}
/**
* Wrap an existing exception in a DTMException.
*
* <p>This is used for throwing processor exceptions before
* the processing has started.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
* @param e Any exception
*/
public DTMException(String message, Throwable e) {
super(message, e);
}
}

View File

@@ -0,0 +1,189 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* Simple filter for doing node tests. Note the semantics of this are
* somewhat different that the DOM's NodeFilter.
*/
public interface DTMFilter
{
// Constants for whatToShow. These are used to set the node type that will
// be traversed. These values may be ORed together before being passed to
// the DTMIterator.
/**
* Show all <code>Nodes</code>.
*/
public static final int SHOW_ALL = 0xFFFFFFFF;
/**
* Show <code>Element</code> nodes.
*/
public static final int SHOW_ELEMENT = 0x00000001;
/**
* Show <code>Attr</code> nodes. This is meaningful only when creating an
* iterator or tree-walker with an attribute node as its
* <code>root</code>; in this case, it means that the attribute node
* will appear in the first position of the iteration or traversal.
* Since attributes are never children of other nodes, they do not
* appear when traversing over the main document tree.
*/
public static final int SHOW_ATTRIBUTE = 0x00000002;
/**
* Show <code>Text</code> nodes.
*/
public static final int SHOW_TEXT = 0x00000004;
/**
* Show <code>CDATASection</code> nodes.
*/
public static final int SHOW_CDATA_SECTION = 0x00000008;
/**
* Show <code>EntityReference</code> nodes. Note that if Entity References
* have been fully expanded while the tree was being constructed, these
* nodes will not appear and this mask has no effect.
*/
public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
/**
* Show <code>Entity</code> nodes. This is meaningful only when creating
* an iterator or tree-walker with an<code> Entity</code> node as its
* <code>root</code>; in this case, it means that the <code>Entity</code>
* node will appear in the first position of the traversal. Since
* entities are not part of the document tree, they do not appear when
* traversing over the main document tree.
*/
public static final int SHOW_ENTITY = 0x00000020;
/**
* Show <code>ProcessingInstruction</code> nodes.
*/
public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
/**
* Show <code>Comment</code> nodes.
*/
public static final int SHOW_COMMENT = 0x00000080;
/**
* Show <code>Document</code> nodes. (Of course, as with Attributes
* and such, this is meaningful only when the iteration root is the
* Document itself, since Document has no parent.)
*/
public static final int SHOW_DOCUMENT = 0x00000100;
/**
* Show <code>DocumentType</code> nodes.
*/
public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
/**
* Show <code>DocumentFragment</code> nodes. (Of course, as with
* Attributes and such, this is meaningful only when the iteration
* root is the Document itself, since DocumentFragment has no parent.)
*/
public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
/**
* Show <code>Notation</code> nodes. This is meaningful only when creating
* an iterator or tree-walker with a <code>Notation</code> node as its
* <code>root</code>; in this case, it means that the
* <code>Notation</code> node will appear in the first position of the
* traversal. Since notations are not part of the document tree, they do
* not appear when traversing over the main document tree.
*/
public static final int SHOW_NOTATION = 0x00000800;
/**
* This bit instructs the iterator to show namespace nodes, which
* are modeled by DTM but not by the DOM. Make sure this does not
* conflict with {@link org.w3c.dom.traversal.NodeFilter}.
* <p>
* %REVIEW% Might be safer to start from higher bits and work down,
* to leave room for the DOM to expand its set of constants... Or,
* possibly, to create a DTM-specific field for these additional bits.
*/
public static final int SHOW_NAMESPACE = 0x00001000;
/**
* Special bit for filters implementing match patterns starting with
* a function. Make sure this does not conflict with
* {@link org.w3c.dom.traversal.NodeFilter}.
* <p>
* %REVIEW% Might be safer to start from higher bits and work down,
* to leave room for the DOM to expand its set of constants... Or,
* possibly, to create a DTM-specific field for these additional bits.
*/
public static final int SHOW_BYFUNCTION = 0x00010000;
/**
* Test whether a specified node is visible in the logical view of a
* <code>DTMIterator</code>. Normally, this function
* will be called by the implementation of <code>DTMIterator</code>;
* it is not normally called directly from
* user code.
*
* @param nodeHandle int Handle of the node.
* @param whatToShow one of SHOW_XXX values.
* @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
*/
public short acceptNode(int nodeHandle, int whatToShow);
/**
* Test whether a specified node is visible in the logical view of a
* <code>DTMIterator</code>. Normally, this function
* will be called by the implementation of <code>DTMIterator</code>;
* it is not normally called directly from
* user code.
* <p>
* TODO: Should this be setNameMatch(expandedName) followed by accept()?
* Or will we really be testing a different name at every invocation?
*
* <p>%REVIEW% Under what circumstances will this be used? The cases
* I've considered are just as easy and just about as efficient if
* the name test is performed in the DTMIterator... -- Joe</p>
*
* <p>%REVIEW% Should that 0xFFFF have a mnemonic assigned to it?
* Also: This representation is assuming the expanded name is indeed
* split into high/low 16-bit halfwords. If we ever change the
* balance between namespace and localname bits (eg because we
* decide there are many more localnames than namespaces, which is
* fairly likely), this is going to break. It might be safer to
* encapsulate the details with a makeExpandedName method and make
* that responsible for setting up the wildcard version as well.</p>
*
* @param nodeHandle int Handle of the node.
* @param whatToShow one of SHOW_XXX values.
* @param expandedName a value defining the exanded name as defined in
* the DTM interface. Wild cards will be defined
* by 0xFFFF in the namespace and/or localname
* portion of the expandedName.
* @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP. */
public short acceptNode(int nodeHandle, int whatToShow, int expandedName);
}

View File

@@ -0,0 +1,345 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* <code>DTMIterators</code> are used to step through a (possibly
* filtered) set of nodes. Their API is modeled largely after the DOM
* NodeIterator.
*
* <p>A DTMIterator is a somewhat unusual type of iterator, in that it
* can serve both single node iteration and random access.</p>
*
* <p>The DTMIterator's traversal semantics, i.e. how it walks the tree,
* are specified when it is created, possibly and probably by an XPath
* <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
* a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.</p>
*
* <p>A DTMIterator is meant to be created once as a master static object, and
* then cloned many times for runtime use. Or the master object itself may
* be used for simpler use cases.</p>
*
* <p>At this time, we do not expect DTMIterator to emulate
* NodeIterator's "maintain relative position" semantics under
* document mutation. It's likely to respond more like the
* TreeWalker's "current node" semantics. However, since the base DTM
* is immutable, this issue currently makes no practical
* difference.</p>
*
* <p>State: In progress!!</p> */
public interface DTMIterator
{
// Constants returned by acceptNode, borrowed from the DOM Traversal chapter
// %REVIEW% Should we explicitly initialize them from, eg,
// org.w3c.dom.traversal.NodeFilter.FILTER_ACCEPT?
/**
* Accept the node.
*/
public static final short FILTER_ACCEPT = 1;
/**
* Reject the node. Same behavior as FILTER_SKIP. (In the DOM these
* differ when applied to a TreeWalker but have the same result when
* applied to a NodeIterator).
*/
public static final short FILTER_REJECT = 2;
/**
* Skip this single node.
*/
public static final short FILTER_SKIP = 3;
/**
* Get an instance of a DTM that "owns" a node handle. Since a node
* iterator may be passed without a DTMManager, this allows the
* caller to easily get the DTM using just the iterator.
*
* @param nodeHandle the nodeHandle.
*
* @return a non-null DTM reference.
*/
public DTM getDTM(int nodeHandle);
/**
* Get an instance of the DTMManager. Since a node
* iterator may be passed without a DTMManager, this allows the
* caller to easily get the DTMManager using just the iterator.
*
* @return a non-null DTMManager reference.
*/
public DTMManager getDTMManager();
/**
* The root node of the <code>DTMIterator</code>, as specified when it
* was created. Note the root node is not the root node of the
* document tree, but the context node from where the iteration
* begins and ends.
*
* @return nodeHandle int Handle of the context node.
*/
public int getRoot();
/**
* Reset the root node of the <code>DTMIterator</code>, overriding
* the value specified when it was created. Note the root node is
* not the root node of the document tree, but the context node from
* where the iteration begins.
*
* @param nodeHandle int Handle of the context node.
* @param environment The environment object.
* The environment in which this iterator operates, which should provide:
* <ul>
* <li>a node (the context node... same value as "root" defined below) </li>
* <li>a pair of non-zero positive integers (the context position and the context size) </li>
* <li>a set of variable bindings </li>
* <li>a function library </li>
* <li>the set of namespace declarations in scope for the expression.</li>
* <ul>
*
* <p>At this time the exact implementation of this environment is application
* dependent. Probably a proper interface will be created fairly soon.</p>
*
*/
public void setRoot(int nodeHandle, Object environment);
/**
* Reset the iterator to the start. After resetting, the next node returned
* will be the root node -- or, if that's filtered out, the first node
* within the root's subtree which is _not_ skipped by the filters.
*/
public void reset();
/**
* This attribute determines which node types are presented via the
* iterator. The available set of constants is defined above.
* Nodes not accepted by
* <code>whatToShow</code> will be skipped, but their children may still
* be considered.
*
* @return one of the SHOW_XXX constants, or several ORed together.
*/
public int getWhatToShow();
/**
* <p>The value of this flag determines whether the children of entity
* reference nodes are visible to the iterator. If false, they and
* their descendants will be rejected. Note that this rejection takes
* precedence over <code>whatToShow</code> and the filter. </p>
*
* <p> To produce a view of the document that has entity references
* expanded and does not expose the entity reference node itself, use
* the <code>whatToShow</code> flags to hide the entity reference node
* and set <code>expandEntityReferences</code> to true when creating the
* iterator. To produce a view of the document that has entity reference
* nodes but no entity expansion, use the <code>whatToShow</code> flags
* to show the entity reference node and set
* <code>expandEntityReferences</code> to false.</p>
*
* <p>NOTE: In Xalan's use of DTM we will generally have fully expanded
* entity references when the document tree was built, and thus this
* flag will have no effect.</p>
*
* @return true if entity references will be expanded. */
public boolean getExpandEntityReferences();
/**
* Returns the next node in the set and advances the position of the
* iterator in the set. After a <code>DTMIterator</code> has setRoot called,
* the first call to <code>nextNode()</code> returns that root or (if it
* is rejected by the filters) the first node within its subtree which is
* not filtered out.
* @return The next node handle in the set being iterated over, or
* <code>DTM.NULL</code> if there are no more members in that set.
*/
public int nextNode();
/**
* Returns the previous node in the set and moves the position of the
* <code>DTMIterator</code> backwards in the set.
* @return The previous node handle in the set being iterated over,
* or <code>DTM.NULL</code> if there are no more members in that set.
*/
public int previousNode();
/**
* Detaches the <code>DTMIterator</code> from the set which it iterated
* over, releasing any computational resources and placing the iterator
* in the INVALID state. After <code>detach</code> has been invoked,
* calls to <code>nextNode</code> or <code>previousNode</code> will
* raise a runtime exception.
*/
public void detach();
/**
* Specify if it's OK for detach to release the iterator for reuse.
*
* @param allowRelease true if it is OK for detach to release this iterator
* for pooling.
*/
public void allowDetachToRelease(boolean allowRelease);
/**
* Get the current node in the iterator. Note that this differs from
* the DOM's NodeIterator, where the current position lies between two
* nodes (as part of the maintain-relative-position semantic).
*
* @return The current node handle, or -1.
*/
public int getCurrentNode();
/**
* Tells if this NodeSetDTM is "fresh", in other words, if
* the first nextNode() that is called will return the
* first node in the set.
*
* @return true if the iteration of this list has not yet begun.
*/
public boolean isFresh();
//========= Random Access ==========
/**
* If setShouldCacheNodes(true) is called, then nodes will
* be cached, enabling random access, and giving the ability to do
* sorts and the like. They are not cached by default.
*
* %REVIEW% Shouldn't the other random-access methods throw an exception
* if they're called on a DTMIterator with this flag set false?
*
* @param b true if the nodes should be cached.
*/
public void setShouldCacheNodes(boolean b);
/**
* Tells if this iterator can have nodes added to it or set via
* the <code>setItem(int node, int index)</code> method.
*
* @return True if the nodelist can be mutated.
*/
public boolean isMutable();
/** Get the current position within the cached list, which is one
* less than the next nextNode() call will retrieve. i.e. if you
* call getCurrentPos() and the return is 0, the next fetch will
* take place at index 1.
*
* @return The position of the iteration.
*/
public int getCurrentPos();
/**
* If an index is requested, NodeSetDTM will call this method
* to run the iterator to the index. By default this sets
* m_next to the index. If the index argument is -1, this
* signals that the iterator should be run to the end and
* completely fill the cache.
*
* @param index The index to run to, or -1 if the iterator should be run
* to the end.
*/
public void runTo(int index);
/**
* Set the current position in the node set.
*
* @param i Must be a valid index.
*/
public void setCurrentPos(int i);
/**
* Returns the <code>node handle</code> of an item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
*
* @param index of the item.
* @return The node handle at the <code>index</code>th position in the
* <code>DTMIterator</code>, or <code>-1</code> if that is not a valid
* index.
*/
public int item(int index);
/**
* Sets the node at the specified index of this vector to be the
* specified node. The previous component at that position is discarded.
*
* <p>The index must be a value greater than or equal to 0 and less
* than the current size of the vector.
* The iterator must be in cached mode.</p>
*
* <p>Meant to be used for sorted iterators.</p>
*
* @param node Node to set
* @param index Index of where to set the node
*/
public void setItem(int node, int index);
/**
* The number of nodes in the list. The range of valid child node indices
* is 0 to <code>length-1</code> inclusive. Note that this requires running
* the iterator to completion, and presumably filling the cache.
*
* @return The number of nodes in the list.
*/
public int getLength();
//=========== Cloning operations. ============
/**
* Get a cloned Iterator that is reset to the start of the iteration.
*
* @return A clone of this iteration that has been reset.
*
* @throws CloneNotSupportedException
*/
public DTMIterator cloneWithReset() throws CloneNotSupportedException;
/**
* Get a clone of this iterator, but don't reset the iteration in the
* process, so that it may be used from the current position.
*
* @return A clone of this object.
*
* @throws CloneNotSupportedException
*/
public Object clone() throws CloneNotSupportedException;
/**
* Returns true if all the nodes in the iteration well be returned in document
* order.
*
* @return true if all the nodes in the iteration well be returned in document
* order.
*/
public boolean isDocOrdered();
/**
* Returns the axis being iterated, if it is known.
*
* @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
* types.
*/
public int getAxis();
}

View File

@@ -0,0 +1,378 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
/**
* A DTMManager instance can be used to create DTM and
* DTMIterator objects, and manage the DTM objects in the system.
*
* <p>The system property that determines which Factory implementation
* to create is named "com.sun.org.apache.xml.internal.utils.DTMFactory". This
* property names a concrete subclass of the DTMFactory abstract
* class. If the property is not defined, a platform default is be used.</p>
*
* <p>An instance of this class <emph>must</emph> be safe to use across
* thread instances. It is expected that a client will create a single instance
* of a DTMManager to use across multiple threads. This will allow sharing
* of DTMs across multiple processes.</p>
*
* <p>Note: this class is incomplete right now. It will be pretty much
* modeled after javax.xml.transform.TransformerFactory in terms of its
* factory support.</p>
*
* <p>State: In progress!!</p>
*/
public abstract class DTMManager
{
/**
* Factory for creating XMLString objects.
* %TBD% Make this set by the caller.
*/
protected XMLStringFactory m_xsf = null;
private boolean _overrideDefaultParser;
/**
* Default constructor is protected on purpose.
*/
protected DTMManager(){}
/**
* Get the XMLStringFactory used for the DTMs.
*
*
* @return a valid XMLStringFactory object, or null if it hasn't been set yet.
*/
public XMLStringFactory getXMLStringFactory()
{
return m_xsf;
}
/**
* Set the XMLStringFactory used for the DTMs.
*
*
* @param xsf a valid XMLStringFactory object, should not be null.
*/
public void setXMLStringFactory(XMLStringFactory xsf)
{
m_xsf = xsf;
}
/**
* Obtain a new instance of a <code>DTMManager</code>.
* This static method creates a new factory instance
* using the default <code>DTMManager</code> implementation, which is
* <code>com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault</code>.
* </li>
* </ul>
*
* Once an application has obtained a reference to a <code>
* DTMManager</code> it can use the factory to configure
* and obtain parser instances.
*
* @return new DTMManager instance, never null.
*
* @throws DTMException
* if the implementation is not available or cannot be instantiated.
*/
public static DTMManager newInstance(XMLStringFactory xsf)
throws DTMException
{
final DTMManager factoryImpl = new com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault();
factoryImpl.setXMLStringFactory(xsf);
return factoryImpl;
}
/**
* Get an instance of a DTM, loaded with the content from the
* specified source. If the unique flag is true, a new instance will
* always be returned. Otherwise it is up to the DTMManager to return a
* new instance or an instance that it already created and may be being used
* by someone else.
*
* (More parameters may eventually need to be added for error handling
* and entity resolution, and to better control selection of implementations.)
*
* @param source the specification of the source object, which may be null,
* in which case it is assumed that node construction will take
* by some other means.
* @param unique true if the returned DTM must be unique, probably because it
* is going to be mutated.
* @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
* be null.
* @param incremental true if the DTM should be built incrementally, if
* possible.
* @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
*
* @return a non-null DTM reference.
*/
public abstract DTM getDTM(javax.xml.transform.Source source,
boolean unique, DTMWSFilter whiteSpaceFilter,
boolean incremental, boolean doIndexing);
/**
* Get the instance of DTM that "owns" a node handle.
*
* @param nodeHandle the nodeHandle.
*
* @return a non-null DTM reference.
*/
public abstract DTM getDTM(int nodeHandle);
/**
* Given a W3C DOM node, try and return a DTM handle.
* Note: calling this may be non-optimal.
*
* @param node Non-null reference to a DOM node.
*
* @return a valid DTM handle.
*/
public abstract int getDTMHandleFromNode(org.w3c.dom.Node node);
/**
* Creates a DTM representing an empty <code>DocumentFragment</code> object.
* @return a non-null DTM reference.
*/
public abstract DTM createDocumentFragment();
/**
* Release a DTM either to a lru pool, or completely remove reference.
* DTMs without system IDs are always hard deleted.
* State: experimental.
*
* @param dtm The DTM to be released.
* @param shouldHardDelete True if the DTM should be removed no matter what.
* @return true if the DTM was removed, false if it was put back in a lru pool.
*/
public abstract boolean release(DTM dtm, boolean shouldHardDelete);
/**
* Create a new <code>DTMIterator</code> based on an XPath
* <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
* a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
*
* @param xpathCompiler ??? Somehow we need to pass in a subpart of the
* expression. I hate to do this with strings, since the larger expression
* has already been parsed.
*
* @param pos The position in the expression.
* @return The newly created <code>DTMIterator</code>.
*/
public abstract DTMIterator createDTMIterator(Object xpathCompiler,
int pos);
/**
* Create a new <code>DTMIterator</code> based on an XPath
* <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
* a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
*
* @param xpathString Must be a valid string expressing a
* <a href="http://www.w3.org/TR/xpath#NT-LocationPath>LocationPath</a> or
* a <a href="http://www.w3.org/TR/xpath#NT-UnionExpr">UnionExpr</a>.
*
* @param presolver An object that can resolve prefixes to namespace URLs.
*
* @return The newly created <code>DTMIterator</code>.
*/
public abstract DTMIterator createDTMIterator(String xpathString,
PrefixResolver presolver);
/**
* Create a new <code>DTMIterator</code> based only on a whatToShow
* and a DTMFilter. The traversal semantics are defined as the
* descendant access.
* <p>
* Note that DTMIterators may not be an exact match to DOM
* NodeIterators. They are initialized and used in much the same way
* as a NodeIterator, but their response to document mutation is not
* currently defined.
*
* @param whatToShow This flag specifies which node types may appear in
* the logical view of the tree presented by the iterator. See the
* description of <code>NodeFilter</code> for the set of possible
* <code>SHOW_</code> values.These flags can be combined using
* <code>OR</code>.
* @param filter The <code>NodeFilter</code> to be used with this
* <code>DTMFilter</code>, or <code>null</code> to indicate no filter.
* @param entityReferenceExpansion The value of this flag determines
* whether entity reference nodes are expanded.
*
* @return The newly created <code>DTMIterator</code>.
*/
public abstract DTMIterator createDTMIterator(int whatToShow,
DTMFilter filter, boolean entityReferenceExpansion);
/**
* Create a new <code>DTMIterator</code> that holds exactly one node.
*
* @param node The node handle that the DTMIterator will iterate to.
*
* @return The newly created <code>DTMIterator</code>.
*/
public abstract DTMIterator createDTMIterator(int node);
/* Flag indicating whether an incremental transform is desired */
public boolean m_incremental = false;
/*
* Flag set by FEATURE_SOURCE_LOCATION.
* This feature specifies whether the transformation phase should
* keep track of line and column numbers for the input source
* document.
*/
public boolean m_source_location = false;
/**
* Get a flag indicating whether an incremental transform is desired
* @return incremental boolean.
*
*/
public boolean getIncremental()
{
return m_incremental;
}
/**
* Set a flag indicating whether an incremental transform is desired
* This flag should have the same value as the FEATURE_INCREMENTAL feature
* which is set by the TransformerFactory.setAttribut() method before a
* DTMManager is created
* @param incremental boolean to use to set m_incremental.
*
*/
public void setIncremental(boolean incremental)
{
m_incremental = incremental;
}
/**
* Get a flag indicating whether the transformation phase should
* keep track of line and column numbers for the input source
* document.
* @return source location boolean
*
*/
public boolean getSource_location()
{
return m_source_location;
}
/**
* Set a flag indicating whether the transformation phase should
* keep track of line and column numbers for the input source
* document.
* This flag should have the same value as the FEATURE_SOURCE_LOCATION feature
* which is set by the TransformerFactory.setAttribut() method before a
* DTMManager is created
* @param sourceLocation boolean to use to set m_source_location
*/
public void setSource_location(boolean sourceLocation){
m_source_location = sourceLocation;
}
/**
* Return the state of the services mechanism feature.
*/
public boolean overrideDefaultParser() {
return _overrideDefaultParser;
}
/**
* Set the state of the services mechanism feature.
*/
public void setOverrideDefaultParser(boolean flag) {
_overrideDefaultParser = flag;
}
// -------------------- private methods --------------------
/** This value, set at compile time, controls how many bits of the
* DTM node identifier numbers are used to identify a node within a
* document, and thus sets the maximum number of nodes per
* document. The remaining bits are used to identify the DTM
* document which contains this node.
*
* If you change IDENT_DTM_NODE_BITS, be sure to rebuild _ALL_ the
* files which use it... including the IDKey testcases.
*
* (FuncGenerateKey currently uses the node identifier directly and
* thus is affected when this changes. The IDKEY results will still be
* _correct_ (presuming no other breakage), but simple equality
* comparison against the previous "golden" files will probably
* complain.)
* */
public static final int IDENT_DTM_NODE_BITS = 16;
/** When this bitmask is ANDed with a DTM node handle number, the result
* is the low bits of the node's index number within that DTM. To obtain
* the high bits, add the DTM ID portion's offset as assigned in the DTM
* Manager.
*/
public static final int IDENT_NODE_DEFAULT = (1<<IDENT_DTM_NODE_BITS)-1;
/** When this bitmask is ANDed with a DTM node handle number, the result
* is the DTM's document identity number.
*/
public static final int IDENT_DTM_DEFAULT = ~IDENT_NODE_DEFAULT;
/** This is the maximum number of DTMs available. The highest DTM is
* one less than this.
*/
public static final int IDENT_MAX_DTMS = (IDENT_DTM_DEFAULT >>> IDENT_DTM_NODE_BITS) + 1;
/**
* %TBD% Doc
*
* NEEDSDOC @param dtm
*
* NEEDSDOC ($objectName$) @return
*/
public abstract int getDTMIdentity(DTM dtm);
/**
* %TBD% Doc
*
* NEEDSDOC ($objectName$) @return
*/
public int getDTMIdentityMask()
{
return IDENT_DTM_DEFAULT;
}
/**
* %TBD% Doc
*
* NEEDSDOC ($objectName$) @return
*/
public int getNodeIdentityMask()
{
return IDENT_NODE_DEFAULT;
}
}

View File

@@ -0,0 +1,57 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm;
/**
* This interface is meant to be implemented by a client of the DTM, and allows
* stripping of whitespace nodes.
*/
public interface DTMWSFilter
{
/**
* Do not strip whitespace child nodes of this element.
*/
public static final short NOTSTRIP = 1;
/**
* Strip whitespace child nodes of this element.
*/
public static final short STRIP = 2;
/**
* Inherit whitespace stripping behavior of the parent node.
*/
public static final short INHERIT = 3;
/**
* Test whether whitespace-only text nodes are visible in the logical
* view of <code>DTM</code>. Normally, this function
* will be called by the implementation of <code>DTM</code>;
* it is not normally called directly from
* user code.
*
* @param elementHandle int Handle of the element.
* @return one of NOTSTRIP, STRIP, or INHERIT.
*/
public short getShouldStripSpace(int elementHandle, DTM dtm);
}

View File

@@ -0,0 +1,307 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
/**
* <code>ChunkedIntArray</code> is an extensible array of blocks of integers.
* (I'd consider Vector, but it's unable to handle integers except by
* turning them into Objects.)
* <p>Making this a separate class means some call-and-return overhead. But
* doing it all inline tends to be fragile and expensive in coder time,
* not to mention driving up code size. If you want to inline it, feel free.
* The Java text suggest that private and Final methods may be inlined,
* and one can argue that this beast need not be made subclassable...</p>
*
* <p>%REVIEW% This has strong conceptual overlap with the IntVector class.
* It would probably be a good thing to merge the two, when time permits.<p>
*/
final class ChunkedIntArray
{
final int slotsize=4; // Locked, MUST be power of two in current code
// Debugging tip: Cranking lowbits down to 4 or so is a good
// way to pound on the array addressing code.
static final int lowbits=10; // How many bits address within chunks
static final int chunkalloc=1<<lowbits;
static final int lowmask=chunkalloc-1;
ChunksVector chunks=new ChunksVector();
final int fastArray[] = new int[chunkalloc];
int lastUsed=0;
/**
* Create a new CIA with specified record size. Currently record size MUST
* be a power of two... and in fact is hardcoded to 4.
*/
ChunkedIntArray(int slotsize)
{
if(this.slotsize<slotsize)
throw new ArrayIndexOutOfBoundsException(XMLMessages.createXMLMessage(XMLErrorResources.ER_CHUNKEDINTARRAY_NOT_SUPPORTED, new Object[]{Integer.toString(slotsize)})); //"ChunkedIntArray("+slotsize+") not currently supported");
else if (this.slotsize>slotsize)
System.out.println("*****WARNING: ChunkedIntArray("+slotsize+") wasting "+(this.slotsize-slotsize)+" words per slot");
chunks.addElement(fastArray);
}
/**
* Append a 4-integer record to the CIA, starting with record 1. (Since
* arrays are initialized to all-0, 0 has been reserved as the "unknown"
* value in DTM.)
* @return the index at which this record was inserted.
*/
int appendSlot(int w0, int w1, int w2, int w3)
{
/*
try
{
int newoffset = (lastUsed+1)*slotsize;
fastArray[newoffset] = w0;
fastArray[newoffset+1] = w1;
fastArray[newoffset+2] = w2;
fastArray[newoffset+3] = w3;
return ++lastUsed;
}
catch(ArrayIndexOutOfBoundsException aioobe)
*/
{
final int slotsize=4;
int newoffset = (lastUsed+1)*slotsize;
int chunkpos = newoffset >> lowbits;
int slotpos = (newoffset & lowmask);
// Grow if needed
if (chunkpos > chunks.size() - 1)
chunks.addElement(new int[chunkalloc]);
int[] chunk = chunks.elementAt(chunkpos);
chunk[slotpos] = w0;
chunk[slotpos+1] = w1;
chunk[slotpos+2] = w2;
chunk[slotpos+3] = w3;
return ++lastUsed;
}
}
/**
* Retrieve an integer from the CIA by record number and column within
* the record, both 0-based (though position 0 is reserved for special
* purposes).
* @param position int Record number
* @param slotpos int Column number
*/
int readEntry(int position, int offset) throws ArrayIndexOutOfBoundsException
{
/*
try
{
return fastArray[(position*slotsize)+offset];
}
catch(ArrayIndexOutOfBoundsException aioobe)
*/
{
// System.out.println("Using slow read (1)");
if (offset>=slotsize)
throw new ArrayIndexOutOfBoundsException(XMLMessages.createXMLMessage(XMLErrorResources.ER_OFFSET_BIGGER_THAN_SLOT, null)); //"Offset bigger than slot");
position*=slotsize;
int chunkpos = position >> lowbits;
int slotpos = position & lowmask;
int[] chunk = chunks.elementAt(chunkpos);
return chunk[slotpos + offset];
}
}
// Check that the node at index "position" is not an ancestor
// of the node at index "startPos". IF IT IS, DO NOT ACCEPT IT AND
// RETURN -1. If position is NOT an ancestor, return position.
// Special case: The Document node (position==0) is acceptable.
//
// This test supports DTM.getNextPreceding.
int specialFind(int startPos, int position)
{
// We have to look all the way up the ancestor chain
// to make sure we don't have an ancestor.
int ancestor = startPos;
while(ancestor > 0)
{
// Get the node whose index == ancestor
ancestor*=slotsize;
int chunkpos = ancestor >> lowbits;
int slotpos = ancestor & lowmask;
int[] chunk = chunks.elementAt(chunkpos);
// Get that node's parent (Note that this assumes w[1]
// is the parent node index. That's really a DTM feature
// rather than a ChunkedIntArray feature.)
ancestor = chunk[slotpos + 1];
if(ancestor == position)
break;
}
if (ancestor <= 0)
{
return position;
}
return -1;
}
/**
* @return int index of highest-numbered record currently in use
*/
int slotsUsed()
{
return lastUsed;
}
/** Disard the highest-numbered record. This is used in the string-buffer
CIA; when only a single characters() chunk has been recieved, its index
is moved into the Text node rather than being referenced by indirection
into the text accumulator.
*/
void discardLast()
{
--lastUsed;
}
/**
* Overwrite the integer found at a specific record and column.
* Used to back-patch existing records, most often changing their
* "next sibling" reference from 0 (unknown) to something meaningful
* @param position int Record number
* @param offset int Column number
* @param value int New contents
*/
void writeEntry(int position, int offset, int value) throws ArrayIndexOutOfBoundsException
{
/*
try
{
fastArray[( position*slotsize)+offset] = value;
}
catch(ArrayIndexOutOfBoundsException aioobe)
*/
{
if (offset >= slotsize)
throw new ArrayIndexOutOfBoundsException(XMLMessages.createXMLMessage(XMLErrorResources.ER_OFFSET_BIGGER_THAN_SLOT, null)); //"Offset bigger than slot");
position*=slotsize;
int chunkpos = position >> lowbits;
int slotpos = position & lowmask;
int[] chunk = chunks.elementAt(chunkpos);
chunk[slotpos + offset] = value; // ATOMIC!
}
}
/**
* Overwrite an entire (4-integer) record at the specified index.
* Mostly used to create record 0, the Document node.
* @param position integer Record number
* @param w0 int
* @param w1 int
* @param w2 int
* @param w3 int
*/
void writeSlot(int position, int w0, int w1, int w2, int w3)
{
position *= slotsize;
int chunkpos = position >> lowbits;
int slotpos = (position & lowmask);
// Grow if needed
if (chunkpos > chunks.size() - 1)
chunks.addElement(new int[chunkalloc]);
int[] chunk = chunks.elementAt(chunkpos);
chunk[slotpos] = w0;
chunk[slotpos + 1] = w1;
chunk[slotpos + 2] = w2;
chunk[slotpos + 3] = w3;
}
/**
* Retrieve the contents of a record into a user-supplied buffer array.
* Used to reduce addressing overhead when code will access several
* columns of the record.
* @param position int Record number
* @param buffer int[] Integer array provided by user, must be large enough
* to hold a complete record.
*/
void readSlot(int position, int[] buffer)
{
/*
try
{
System.arraycopy(fastArray, position*slotsize, buffer, 0, slotsize);
}
catch(ArrayIndexOutOfBoundsException aioobe)
*/
{
// System.out.println("Using slow read (2): "+position);
position *= slotsize;
int chunkpos = position >> lowbits;
int slotpos = (position & lowmask);
// Grow if needed
if (chunkpos > chunks.size() - 1)
chunks.addElement(new int[chunkalloc]);
int[] chunk = chunks.elementAt(chunkpos);
System.arraycopy(chunk,slotpos,buffer,0,slotsize);
}
}
class ChunksVector
{
final int BLOCKSIZE = 64;
int[] m_map[] = new int[BLOCKSIZE][];
int m_mapSize = BLOCKSIZE;
int pos = 0;
ChunksVector()
{
}
final int size()
{
return pos;
}
void addElement(int[] value)
{
if(pos >= m_mapSize)
{
int orgMapSize = m_mapSize;
while(pos >= m_mapSize)
m_mapSize+=BLOCKSIZE;
int[] newMap[] = new int[m_mapSize][];
System.arraycopy(m_map, 0, newMap, 0, orgMapSize);
m_map = newMap;
}
// For now, just do a simple append. A sorted insert only
// makes sense if we're doing an binary search or some such.
m_map[pos] = value;
pos++;
}
final int[] elementAt(int pos)
{
return m_map[pos];
}
}
}

View File

@@ -0,0 +1,345 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import java.util.BitSet;
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
/**
* <p>Support the coroutine design pattern.</p>
*
* <p>A coroutine set is a very simple cooperative non-preemptive
* multitasking model, where the switch from one task to another is
* performed via an explicit request. Coroutines interact according to
* the following rules:</p>
*
* <ul>
* <li>One coroutine in the set has control, which it retains until it
* either exits or resumes another coroutine.</li>
* <li>A coroutine is activated when it is resumed by some other coroutine
* for the first time.</li>
* <li>An active coroutine that gives up control by resuming another in
* the set retains its context -- including call stack and local variables
* -- so that if/when it is resumed, it will proceed from the point at which
* it last gave up control.</li>
* </ul>
*
* <p>Coroutines can be thought of as falling somewhere between pipes and
* subroutines. Like call/return, there is an explicit flow of control
* from one coroutine to another. Like pipes, neither coroutine is
* actually "in charge", and neither must exit in order to transfer
* control to the other. </p>
*
* <p>One classic application of coroutines is in compilers, where both
* the parser and the lexer are maintaining complex state
* information. The parser resumes the lexer to process incoming
* characters into lexical tokens, and the lexer resumes the parser
* when it has reached a point at which it has a reliably interpreted
* set of tokens available for semantic processing. Structuring this
* as call-and-return would require saving and restoring a
* considerable amount of state each time. Structuring it as two tasks
* connected by a queue may involve higher overhead (in systems which
* can optimize the coroutine metaphor), isn't necessarily as clear in
* intent, may have trouble handling cases where data flows in both
* directions, and may not handle some of the more complex cases where
* more than two coroutines are involved.</p>
*
* <p>Most coroutine systems also provide a way to pass data between the
* source and target of a resume operation; this is sometimes referred
* to as "yielding" a value. Others rely on the fact that, since only
* one member of a coroutine set is running at a time and does not
* lose control until it chooses to do so, data structures may be
* directly shared between them with only minimal precautions.</p>
*
* <p>"Note: This should not be taken to mean that producer/consumer
* problems should be always be done with coroutines." Queueing is
* often a better solution when only two threads of execution are
* involved and full two-way handshaking is not required. It's a bit
* difficult to find short pedagogical examples that require
* coroutines for a clear solution.</p>
*
* <p>The fact that only one of a group of coroutines is running at a
* time, and the control transfer between them is explicit, simplifies
* their possible interactions, and in some implementations permits
* them to be implemented more efficiently than general multitasking.
* In some situations, coroutines can be compiled out entirely;
* in others, they may only require a few instructions more than a
* simple function call.</p>
*
* <p>This version is built on top of standard Java threading, since
* that's all we have available right now. It's been encapsulated for
* code clarity and possible future optimization.</p>
*
* <p>(Two possible approaches: wait-notify based and queue-based. Some
* folks think that a one-item queue is a cleaner solution because it's
* more abstract -- but since coroutine _is_ an abstraction I'm not really
* worried about that; folks should be able to switch this code without
* concern.)</p>
*
* <p>%TBD% THIS SHOULD BE AN INTERFACE, to facilitate building other
* implementations... perhaps including a true coroutine system
* someday, rather than controlled threading. Arguably Coroutine
* itself should be an interface much like Runnable, but I think that
* can be built on top of this.</p>
* */
public class CoroutineManager
{
/** "Is this coroutine ID number already in use" lookup table.
* Currently implemented as a bitset as a compromise between
* compactness and speed of access, but obviously other solutions
* could be applied.
* */
BitSet m_activeIDs=new BitSet();
/** Limit on the coroutine ID numbers accepted. I didn't want the
* in-use table to grow without bound. If we switch to a more efficient
* sparse-array mechanism, it may be possible to raise or eliminate
* this boundary.
* @xsl.usage internal
*/
static final int m_unreasonableId=1024;
/** Internal field used to hold the data being explicitly passed
* from one coroutine to another during a co_resume() operation.
* (Of course implicit data sharing may also occur; one of the reasons
* for using coroutines is that you're guaranteed that none of the
* other coroutines in your set are using shared structures at the time
* you access them.)
*
* %REVIEW% It's been proposed that we be able to pass types of data
* other than Object -- more specific object types, or
* lighter-weight primitives. This would seem to create a potential
* explosion of "pass x recieve y back" methods (or require
* fracturing resume into two calls, resume-other and
* wait-to-be-resumed), and the weight issue could be managed by
* reusing a mutable buffer object to contain the primitive
* (remember that only one coroutine runs at a time, so once the
* buffer's set it won't be walked on). Typechecking objects is
* interesting from a code-robustness point of view, but it's
* unclear whether it makes sense to encapsulate that in the
* coroutine code or let the callers do it, since it depends on RTTI
* either way. Restricting the parameters to objects implementing a
* specific CoroutineParameter interface does _not_ seem to be a net
* win; applications can do so if they want via front-end code, but
* there seem to be too many use cases involving passing an existing
* object type that you may not have the freedom to alter and may
* not want to spend time wrapping another object around.
* */
Object m_yield=null;
// Expose???
final static int NOBODY=-1;
final static int ANYBODY=-1;
/** Internal field used to confirm that the coroutine now waking up is
* in fact the one we intended to resume. Some such selection mechanism
* is needed when more that two coroutines are operating within the same
* group.
*/
int m_nextCoroutine=NOBODY;
/** <p>Each coroutine in the set managed by a single
* CoroutineManager is identified by a small positive integer. This
* brings up the question of how to manage those integers to avoid
* reuse... since if two coroutines use the same ID number, resuming
* that ID could resume either. I can see arguments for either
* allowing applications to select their own numbers (they may want
* to declare mnemonics via manefest constants) or generating
* numbers on demand. This routine's intended to support both
* approaches.</p>
*
* <p>%REVIEW% We could use an object as the identifier. Not sure
* it's a net gain, though it would allow the thread to be its own
* ID. Ponder.</p>
*
* @param coroutineID If >=0, requests that we reserve this number.
* If <0, requests that we find, reserve, and return an available ID
* number.
*
* @return If >=0, the ID number to be used by this coroutine. If <0,
* an error occurred -- the ID requested was already in use, or we
* couldn't assign one without going over the "unreasonable value" mark
* */
public synchronized int co_joinCoroutineSet(int coroutineID)
{
if(coroutineID>=0)
{
if(coroutineID>=m_unreasonableId || m_activeIDs.get(coroutineID))
return -1;
}
else
{
// What I want is "Find first clear bit". That doesn't exist.
// JDK1.2 added "find last set bit", but that doesn't help now.
coroutineID=0;
while(coroutineID<m_unreasonableId)
{
if(m_activeIDs.get(coroutineID))
++coroutineID;
else
break;
}
if(coroutineID>=m_unreasonableId)
return -1;
}
m_activeIDs.set(coroutineID);
return coroutineID;
}
/** In the standard coroutine architecture, coroutines are
* identified by their method names and are launched and run up to
* their first yield by simply resuming them; its's presumed that
* this recognizes the not-already-running case and does the right
* thing. We seem to need a way to achieve that same threadsafe
* run-up... eg, start the coroutine with a wait.
*
* %TBD% whether this makes any sense...
*
* @param thisCoroutine the identifier of this coroutine, so we can
* recognize when we are being resumed.
* @exception java.lang.NoSuchMethodException if thisCoroutine isn't
* a registered member of this group. %REVIEW% whether this is the
* best choice.
* */
public synchronized Object co_entry_pause(int thisCoroutine) throws java.lang.NoSuchMethodException
{
if(!m_activeIDs.get(thisCoroutine))
throw new java.lang.NoSuchMethodException();
while(m_nextCoroutine != thisCoroutine)
{
try
{
wait();
}
catch(java.lang.InterruptedException e)
{
// %TBD% -- Declare? Encapsulate? Ignore? Or
// dance widdershins about the instruction cache?
}
}
return m_yield;
}
/** Transfer control to another coroutine which has already been started and
* is waiting on this CoroutineManager. We won't return from this call
* until that routine has relinquished control.
*
* %TBD% What should we do if toCoroutine isn't registered? Exception?
*
* @param arg_object A value to be passed to the other coroutine.
* @param thisCoroutine Integer identifier for this coroutine. This is the
* ID we watch for to see if we're the ones being resumed.
* @param toCoroutine Integer identifier for the coroutine we wish to
* invoke.
* @exception java.lang.NoSuchMethodException if toCoroutine isn't a
* registered member of this group. %REVIEW% whether this is the best choice.
* */
public synchronized Object co_resume(Object arg_object,int thisCoroutine,int toCoroutine) throws java.lang.NoSuchMethodException
{
if(!m_activeIDs.get(toCoroutine))
throw new java.lang.NoSuchMethodException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COROUTINE_NOT_AVAIL, new Object[]{Integer.toString(toCoroutine)})); //"Coroutine not available, id="+toCoroutine);
// We expect these values to be overwritten during the notify()/wait()
// periods, as other coroutines in this set get their opportunity to run.
m_yield=arg_object;
m_nextCoroutine=toCoroutine;
notify();
while(m_nextCoroutine != thisCoroutine || m_nextCoroutine==ANYBODY || m_nextCoroutine==NOBODY)
{
try
{
// System.out.println("waiting...");
wait();
}
catch(java.lang.InterruptedException e)
{
// %TBD% -- Declare? Encapsulate? Ignore? Or
// dance deasil about the program counter?
}
}
if(m_nextCoroutine==NOBODY)
{
// Pass it along
co_exit(thisCoroutine);
// And inform this coroutine that its partners are Going Away
// %REVIEW% Should this throw/return something more useful?
throw new java.lang.NoSuchMethodException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COROUTINE_CO_EXIT, null)); //"CoroutineManager recieved co_exit() request");
}
return m_yield;
}
/** Terminate this entire set of coroutines. The others will be
* deregistered and have exceptions thrown at them. Note that this
* is intended as a panic-shutdown operation; under normal
* circumstances a coroutine should always end with co_exit_to() in
* order to politely inform at least one of its partners that it is
* going away.
*
* %TBD% This may need significantly more work.
*
* %TBD% Should this just be co_exit_to(,,CoroutineManager.PANIC)?
*
* @param thisCoroutine Integer identifier for the coroutine requesting exit.
* */
public synchronized void co_exit(int thisCoroutine)
{
m_activeIDs.clear(thisCoroutine);
m_nextCoroutine=NOBODY; // %REVIEW%
notify();
}
/** Make the ID available for reuse and terminate this coroutine,
* transferring control to the specified coroutine. Note that this
* returns immediately rather than waiting for any further coroutine
* traffic, so the thread can proceed with other shutdown activities.
*
* @param arg_object A value to be passed to the other coroutine.
* @param thisCoroutine Integer identifier for the coroutine leaving the set.
* @param toCoroutine Integer identifier for the coroutine we wish to
* invoke.
* @exception java.lang.NoSuchMethodException if toCoroutine isn't a
* registered member of this group. %REVIEW% whether this is the best choice.
* */
public synchronized void co_exit_to(Object arg_object,int thisCoroutine,int toCoroutine) throws java.lang.NoSuchMethodException
{
if(!m_activeIDs.get(toCoroutine))
throw new java.lang.NoSuchMethodException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COROUTINE_NOT_AVAIL, new Object[]{Integer.toString(toCoroutine)})); //"Coroutine not available, id="+toCoroutine);
// We expect these values to be overwritten during the notify()/wait()
// periods, as other coroutines in this set get their opportunity to run.
m_yield=arg_object;
m_nextCoroutine=toCoroutine;
m_activeIDs.clear(thisCoroutine);
notify();
}
}

View File

@@ -0,0 +1,140 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
/** <p>CoroutineParser is an API for parser threads that operate as
* coroutines. See CoroutineSAXParser and CoroutineSAXParser_Xerces
* for examples.</p>
*
* <p>&lt;grumble&gt; I'd like the interface to require a specific form
* for either the base constructor or a static factory method. Java
* doesn't allow us to specify either, so I'll just document them
* here:
*
* <ul>
* <li>public CoroutineParser(CoroutineManager co, int appCoroutine);</li>
* <li>public CoroutineParser createCoroutineParser(CoroutineManager co, int appCoroutine);</li>
* </ul>
*
* &lt;/grumble&gt;</p>
*
* @deprecated Since the ability to start a parse via the
* coroutine protocol was not being used and was complicating design.
* See {@link IncrementalSAXSource}.
* */
public interface CoroutineParser {
/** @return the coroutine ID number for this CoroutineParser object.
* Note that this isn't useful unless you know which CoroutineManager
* you're talking to. Also note that the do...() methods encapsulate
* the common transactions with the CoroutineParser, so you shouldn't
* need this in most cases.
* */
public int getParserCoroutineID();
/** @return the CoroutineManager for this CoroutineParser object.
* If you're using the do...() methods, applications should only
* need to talk to the CoroutineManager once, to obtain the
* application's Coroutine ID.
* */
public CoroutineManager getCoroutineManager();
/** Register a SAX-style content handler for us to output to */
public void setContentHandler(ContentHandler handler);
/** Register a SAX-style lexical handler for us to output to
* Not all parsers support this...
*
* %REVIEW% Not called setLexicalHandler because Xalan uses that name
* internally, which causes subclassing nuisances.
*/
public void setLexHandler(org.xml.sax.ext.LexicalHandler handler);
/* The run() method is required in CoroutineParsers that run as
* threads (of course)... but it isn't part of our API, and
* shouldn't be declared here.
* */
//================================================================
/** doParse() is a simple API which tells the coroutine parser
* to begin reading from a file. This is intended to be called from one
* of our partner coroutines, and serves both to encapsulate the
* communication protocol and to avoid having to explicitly use the
* CoroutineParser's coroutine ID number.
*
* %REVIEW% Can/should this unify with doMore? (if URI hasn't changed,
* parse more from same file, else end and restart parsing...?
*
* @param source The InputSource to parse from.
* @param appCoroutine The coroutine ID number of the coroutine invoking
* this method, so it can be resumed after the parser has responded to the
* request.
* @return Boolean.TRUE if the CoroutineParser believes more data may be available
* for further parsing. Boolean.FALSE if parsing ran to completion.
* Exception if the parser objected for some reason.
* */
public Object doParse(InputSource source, int appCoroutine);
/** doMore() is a simple API which tells the coroutine parser
* that we need more nodes. This is intended to be called from one
* of our partner coroutines, and serves both to encapsulate the
* communication protocol and to avoid having to explicitly use the
* CoroutineParser's coroutine ID number.
*
* @param parsemore If true, tells the incremental parser to generate
* another chunk of output. If false, tells the parser that we're
* satisfied and it can terminate parsing of this document.
* @param appCoroutine The coroutine ID number of the coroutine invoking
* this method, so it can be resumed after the parser has responded to the
* request.
* @return Boolean.TRUE if the CoroutineParser believes more data may be available
* for further parsing. Boolean.FALSE if parsing ran to completion.
* Exception if the parser objected for some reason.
* */
public Object doMore (boolean parsemore, int appCoroutine);
/** doTerminate() is a simple API which tells the coroutine
* parser to terminate itself. This is intended to be called from
* one of our partner coroutines, and serves both to encapsulate the
* communication protocol and to avoid having to explicitly use the
* CoroutineParser's coroutine ID number.
*
* Returns only after the CoroutineParser has acknowledged the request.
*
* @param appCoroutine The coroutine ID number of the coroutine invoking
* this method, so it can be resumed after the parser has responded to the
* request.
* */
public void doTerminate(int appCoroutine);
/**
* Initialize the coroutine parser. Same parameters could be passed
* in a non-default constructor, or by using using context ClassLoader
* and newInstance and then calling init()
*/
public void init( CoroutineManager co, int appCoroutineID, XMLReader parser );
} // class CoroutineParser

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: CustomStringPool.java,v 1.2.4.1 2005/09/15 08:14:59 suresh_emailid Exp $
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import java.util.HashMap;
import java.util.Map;
/**
* CustomStringPool is an example of an application-provided data structure for a
* DTM implementation to hold symbol references, e.g. element names. It will
* follow the DTMStringPool interface and use two simple methods
* indexToString(int i) and stringToIndex(String s) to map between a set of
* string values and a set of integer index values. Therefore, an application
* may improve DTM processing speed by substituting the DTM symbol resolution
* tables with application specific quick symbol resolution tables.
* <p>
* %REVIEW% The only difference between this an DTMStringPool seems to be that
* it uses a java.lang.Hashtable full of Integers rather than implementing its
* own hashing. Joe deliberately avoided that approach when writing
* DTMStringPool, since it is both much more memory-hungry and probably slower
* -- especially in JDK 1.1.x, where Hashtable is synchronized. We need to
* either justify this implementation or discard it.
*
* <p>
* Status: In progress, under discussion.
*
*/
public class CustomStringPool extends DTMStringPool {
final Map<String, Integer> m_stringToInt = new HashMap<>();
public static final int NULL = -1;
public CustomStringPool() {
super();
}
public void removeAllElements() {
m_intToString.removeAllElements();
if (m_stringToInt != null) {
m_stringToInt.clear();
}
}
/**
* @return string whose value is uniquely identified by this integer index.
* @throws java.lang.ArrayIndexOutOfBoundsException if index doesn't map to
* a string.
*/
@Override
public String indexToString(int i)
throws java.lang.ArrayIndexOutOfBoundsException {
return (String) m_intToString.elementAt(i);
}
/**
* @return integer index uniquely identifying the value of this string.
*/
@Override
public int stringToIndex(String s) {
if (s == null) {
return NULL;
}
Integer iobj = m_stringToInt.get(s);
if (iobj == null) {
m_intToString.addElement(s);
iobj = m_intToString.size();
m_stringToInt.put(s, iobj);
}
return iobj;
}
}

View File

@@ -0,0 +1,143 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.utils.IntVector;
import org.w3c.dom.Node;
/**
* <code>DTMAxisNodeList</code> gives us an implementation of the DOM's
* NodeList interface wrapped around a DTM Iterator. The author
* considers this something of an abominations, since NodeList was not
* intended to be a general purpose "list of nodes" API and is
* generally considered by the DOM WG to have be a mistake... but I'm
* told that some of the XPath/XSLT folks say they must have this
* solution.
*
* Please note that this is not necessarily equivlaent to a DOM
* NodeList operating over the same document. In particular:
* <ul>
*
* <li>If there are several Text nodes in logical succession (ie,
* across CDATASection and EntityReference boundaries), we will return
* only the first; the caller is responsible for stepping through
* them.
* (%REVIEW% Provide a convenience routine here to assist, pending
* proposed DOM Level 3 getAdjacentText() operation?) </li>
*
* <li>Since the whole XPath/XSLT architecture assumes that the source
* document is not altered while we're working with it, we do not
* promise to implement the DOM NodeList's "live view" response to
* document mutation. </li>
*
* </ul>
*
* <p>State: In progress!!</p>
* */
public class DTMAxisIterNodeList extends DTMNodeListBase {
private DTM m_dtm;
private DTMAxisIterator m_iter;
private IntVector m_cachedNodes;
private int m_last = -1;
//================================================================
// Methods unique to this class
private DTMAxisIterNodeList() {
}
/**
* Public constructor: Wrap a DTMNodeList around an existing
* and preconfigured DTMAxisIterator
*/
public DTMAxisIterNodeList(DTM dtm, DTMAxisIterator dtmAxisIterator) {
if (dtmAxisIterator == null) {
m_last = 0;
} else {
m_cachedNodes = new IntVector();
m_dtm = dtm;
}
m_iter = dtmAxisIterator;
}
/**
* Access the wrapped DTMIterator. I'm not sure whether anyone will
* need this or not, but let's write it and think about it.
*
*/
public DTMAxisIterator getDTMAxisIterator() {
return m_iter;
}
//================================================================
// org.w3c.dom.NodeList API follows
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
public Node item(int index) {
if (m_iter != null) {
int node = 0;
int count = m_cachedNodes.size();
if (count > index) {
node = m_cachedNodes.elementAt(index);
return m_dtm.getNode(node);
} else if (m_last == -1) {
while (count <= index
&& ((node = m_iter.next()) != DTMAxisIterator.END)) {
m_cachedNodes.addElement(node);
count++;
}
if (node == DTMAxisIterator.END) {
m_last = count;
} else {
return m_dtm.getNode(node);
}
}
}
return null;
}
/**
* The number of nodes in the list. The range of valid child node indices
* is 0 to <code>length-1</code> inclusive.
*/
public int getLength() {
if (m_last == -1) {
int node;
while ((node = m_iter.next()) != DTMAxisIterator.END) {
m_cachedNodes.addElement(node);
}
m_last = m_cachedNodes.size();
}
return m_last;
}
}

View File

@@ -0,0 +1,282 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
/**
* This class serves as a default base for implementations of mutable
* DTMAxisIterators.
*/
public abstract class DTMAxisIteratorBase implements DTMAxisIterator
{
/** The position of the last node within the iteration, as defined by XPath.
* Note that this is _not_ the node's handle within the DTM. Also, don't
* confuse it with the current (most recently returned) position.
*/
protected int _last = -1;
/** The position of the current node within the iteration, as defined by XPath.
* Note that this is _not_ the node's handle within the DTM!
*/
protected int _position = 0;
/** The position of the marked node within the iteration;
* a saved itaration state that we may want to come back to.
* Note that only one mark is maintained; there is no stack.
*/
protected int _markedNode;
/** The handle to the start, or root, of the iteration.
* Set this to END to construct an empty iterator.
*/
protected int _startNode = DTMAxisIterator.END;
/** True if the start node should be considered part of the iteration.
* False will cause it to be skipped.
*/
protected boolean _includeSelf = false;
/** True if this iteration can be restarted. False otherwise (eg, if
* we are iterating over a stream that can not be re-scanned, or if
* the iterator was produced by cloning another iterator.)
*/
protected boolean _isRestartable = true;
/**
* Get start to END should 'close' the iterator,
* i.e. subsequent call to next() should return END.
*
* @return The root node of the iteration.
*/
public int getStartNode()
{
return _startNode;
}
/**
* @return A DTMAxisIterator which has been reset to the start node,
* which may or may not be the same as this iterator.
* */
public DTMAxisIterator reset()
{
final boolean temp = _isRestartable;
_isRestartable = true;
setStartNode(_startNode);
_isRestartable = temp;
return this;
}
/**
* Set the flag to include the start node in the iteration.
*
*
* @return This default method returns just returns this DTMAxisIterator,
* after setting the flag.
* (Returning "this" permits C++-style chaining of
* method calls into a single expression.)
*/
public DTMAxisIterator includeSelf()
{
_includeSelf = true;
return this;
}
/** Returns the position of the last node within the iteration, as
* defined by XPath. In a forward iterator, I believe this equals the number of nodes which this
* iterator will yield. In a reverse iterator, I believe it should return
* 1 (since the "last" is the first produced.)
*
* This may be an expensive operation when called the first time, since
* it may have to iterate through a large part of the document to produce
* its answer.
*
* @return The number of nodes in this iterator (forward) or 1 (reverse).
*/
public int getLast()
{
if (_last == -1) // Not previously established
{
// Note that we're doing both setMark() -- which saves _currentChild
// -- and explicitly saving our position counter (number of nodes
// yielded so far).
//
// %REVIEW% Should position also be saved by setMark()?
// (It wasn't in the XSLTC version, but I don't understand why not.)
final int temp = _position; // Save state
setMark();
reset(); // Count the nodes found by this iterator
do
{
_last++;
}
while (next() != END);
gotoMark(); // Restore saved state
_position = temp;
}
return _last;
}
/**
* @return The position of the current node within the set, as defined by
* XPath. Note that this is one-based, not zero-based.
*/
public int getPosition()
{
return _position == 0 ? 1 : _position;
}
/**
* @return true if this iterator has a reversed axis, else false
*/
public boolean isReverse()
{
return false;
}
/**
* Returns a deep copy of this iterator. Cloned iterators may not be
* restartable. The iterator being cloned may or may not become
* non-restartable as a side effect of this operation.
*
* @return a deep copy of this iterator.
*/
public DTMAxisIterator cloneIterator()
{
try
{
final DTMAxisIteratorBase clone = (DTMAxisIteratorBase) super.clone();
clone._isRestartable = false;
// return clone.reset();
return clone;
}
catch (CloneNotSupportedException e)
{
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
}
}
/**
* Do any final cleanup that is required before returning the node that was
* passed in, and then return it. The intended use is
* <br />
* <code>return returnNode(node);</code>
*
* %REVIEW% If we're calling it purely for side effects, should we really
* be bothering with a return value? Something like
* <br />
* <code> accept(node); return node; </code>
* <br />
* would probably optimize just about as well and avoid questions
* about whether what's returned could ever be different from what's
* passed in.
*
* @param node Node handle which iteration is about to yield.
*
* @return The node handle passed in. */
protected final int returnNode(final int node)
{
_position++;
return node;
}
/**
* Reset the position to zero. NOTE that this does not change the iteration
* state, only the position number associated with that state.
*
* %REVIEW% Document when this would be used?
*
* @return This instance.
*/
protected final DTMAxisIterator resetPosition()
{
_position = 0;
return this;
}
/**
* Returns true if all the nodes in the iteration well be returned in document
* order.
*
* @return true as a default.
*/
public boolean isDocOrdered()
{
return true;
}
/**
* Returns the axis being iterated, if it is known.
*
* @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
* types.
*/
public int getAxis()
{
return -1;
}
public void setRestartable(boolean isRestartable) {
_isRestartable = isRestartable;
}
/**
* Return the node at the given position.
*
* @param position The position
* @return The node at the given position.
*/
public int getNodeByPosition(int position)
{
if (position > 0) {
final int pos = isReverse() ? getLast() - position + 1
: position;
int node;
while ((node = next()) != DTMAxisIterator.END) {
if (pos == getPosition()) {
return node;
}
}
}
return END;
}
}

View File

@@ -0,0 +1,120 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
import org.w3c.dom.Node;
/**
* <code>DTMNodeList</code> gives us an implementation of the DOM's
* NodeList interface wrapped around a DTM Iterator. The author
* considers this something of an abominations, since NodeList was not
* intended to be a general purpose "list of nodes" API and is
* generally considered by the DOM WG to have be a mistake... but I'm
* told that some of the XPath/XSLT folks say they must have this
* solution.
*
* Please note that this is not necessarily equivlaent to a DOM
* NodeList operating over the same document. In particular:
* <ul>
*
* <li>If there are several Text nodes in logical succession (ie,
* across CDATASection and EntityReference boundaries), we will return
* only the first; the caller is responsible for stepping through
* them.
* (%REVIEW% Provide a convenience routine here to assist, pending
* proposed DOM Level 3 getAdjacentText() operation?) </li>
*
* <li>Since the whole XPath/XSLT architecture assumes that the source
* document is not altered while we're working with it, we do not
* promise to implement the DOM NodeList's "live view" response to
* document mutation. </li>
*
* </ul>
*
* <p>State: In progress!!</p>
* */
public class DTMChildIterNodeList extends DTMNodeListBase {
private int m_firstChild;
private DTM m_parentDTM;
//================================================================
// Methods unique to this class
private DTMChildIterNodeList() {
}
/**
* Public constructor: Create a NodeList to support
* DTMNodeProxy.getChildren().
*
* Unfortunately AxisIterators and DTMIterators don't share an API,
* so I can't use the existing Axis.CHILD iterator. Rather than
* create Yet Another Class, let's set up a special case of this
* one.
*
* @param parentDTM The DTM containing this node
* @param parentHandle DTM node-handle integer
*
*/
public DTMChildIterNodeList(DTM parentDTM,int parentHandle) {
m_parentDTM=parentDTM;
m_firstChild=parentDTM.getFirstChild(parentHandle);
}
//================================================================
// org.w3c.dom.NodeList API follows
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
public Node item(int index) {
int handle=m_firstChild;
while(--index>=0 && handle!=DTM.NULL) {
handle=m_parentDTM.getNextSibling(handle);
}
if (handle == DTM.NULL) {
return null;
}
return m_parentDTM.getNode(handle);
}
/**
* The number of nodes in the list. The range of valid child node indices
* is 0 to <code>length-1</code> inclusive.
*/
public int getLength() {
int count=0;
for (int handle=m_firstChild;
handle!=DTM.NULL;
handle=m_parentDTM.getNextSibling(handle)) {
++count;
}
return count;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,858 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMException;
import com.sun.org.apache.xml.internal.dtm.DTMFilter;
import com.sun.org.apache.xml.internal.dtm.DTMIterator;
import com.sun.org.apache.xml.internal.dtm.DTMManager;
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
import com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM;
import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM;
import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2RTFDTM;
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
import com.sun.org.apache.xml.internal.utils.PrefixResolver;
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
import com.sun.org.apache.xml.internal.utils.XMLReaderManager;
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
import jdk.xml.internal.JdkXmlUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
/**
* The default implementation for the DTMManager.
*
* %REVIEW% There is currently a reentrancy issue, since the finalizer
* for XRTreeFrag (which runs in the GC thread) wants to call
* DTMManager.release(), and may do so at the same time that the main
* transformation thread is accessing the manager. Our current solution is
* to make most of the manager's methods <code>synchronized</code>.
* Early tests suggest that doing so is not causing a significant
* performance hit in Xalan. However, it should be noted that there
* is a possible alternative solution: rewrite release() so it merely
* posts a request for release onto a threadsafe queue, and explicitly
* process that queue on an infrequent basis during main-thread
* activity (eg, when getDTM() is invoked). The downside of that solution
* would be a greater delay before the DTM's storage is actually released
* for reuse.
* */
public class DTMManagerDefault extends DTMManager
{
//static final boolean JKESS_XNI_EXPERIMENT=true;
/** Set this to true if you want a dump of the DTM after creation. */
private static final boolean DUMPTREE = false;
/** Set this to true if you want a basic diagnostics. */
private static final boolean DEBUG = false;
/**
* Map from DTM identifier numbers to DTM objects that this manager manages.
* One DTM may have several prefix numbers, if extended node indexing
* is in use; in that case, m_dtm_offsets[] will used to control which
* prefix maps to which section of the DTM.
*
* This array grows as necessary; see addDTM().
*
* This array grows as necessary; see addDTM(). Growth is uncommon... but
* access needs to be blindingly fast since it's used in node addressing.
*/
protected DTM m_dtms[] = new DTM[256];
/** Map from DTM identifier numbers to offsets. For small DTMs with a
* single identifier, this will always be 0. In overflow addressing, where
* additional identifiers are allocated to access nodes beyond the range of
* a single Node Handle, this table is used to map the handle's node field
* into the actual node identifier.
*
* This array grows as necessary; see addDTM().
*
* This array grows as necessary; see addDTM(). Growth is uncommon... but
* access needs to be blindingly fast since it's used in node addressing.
* (And at the moment, that includes accessing it from DTMDefaultBase,
* which is why this is not Protected or Private.)
*/
int m_dtm_offsets[] = new int[256];
/**
* The cache for XMLReader objects to be used if the user did not
* supply an XMLReader for a SAXSource or supplied a StreamSource.
*/
protected XMLReaderManager m_readerManager = null;
/**
* The default implementation of ContentHandler, DTDHandler and ErrorHandler.
*/
protected DefaultHandler m_defaultHandler = new DefaultHandler();
/**
* Add a DTM to the DTM table. This convenience call adds it as the
* "base DTM ID", with offset 0. The other version of addDTM should
* be used if you want to add "extended" DTM IDs with nonzero offsets.
*
* @param dtm Should be a valid reference to a DTM.
* @param id Integer DTM ID to be bound to this DTM
*/
synchronized public void addDTM(DTM dtm, int id) { addDTM(dtm,id,0); }
/**
* Add a DTM to the DTM table.
*
* @param dtm Should be a valid reference to a DTM.
* @param id Integer DTM ID to be bound to this DTM.
* @param offset Integer addressing offset. The internal DTM Node ID is
* obtained by adding this offset to the node-number field of the
* public DTM Handle. For the first DTM ID accessing each DTM, this is 0;
* for overflow addressing it will be a multiple of 1<<IDENT_DTM_NODE_BITS.
*/
synchronized public void addDTM(DTM dtm, int id, int offset)
{
if(id>=IDENT_MAX_DTMS)
{
// TODO: %REVIEW% Not really the right error message.
throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NO_DTMIDS_AVAIL, null)); //"No more DTM IDs are available!");
}
// We used to just allocate the array size to IDENT_MAX_DTMS.
// But we expect to increase that to 16 bits, and I'm not willing
// to allocate that much space unless needed. We could use one of our
// handy-dandy Fast*Vectors, but this will do for now.
// %REVIEW%
int oldlen=m_dtms.length;
if(oldlen<=id)
{
// Various growth strategies are possible. I think we don't want
// to over-allocate excessively, and I'm willing to reallocate
// more often to get that. See also Fast*Vector classes.
//
// %REVIEW% Should throw a more diagnostic error if we go over the max...
int newlen=Math.min((id+256),IDENT_MAX_DTMS);
DTM new_m_dtms[] = new DTM[newlen];
System.arraycopy(m_dtms,0,new_m_dtms,0,oldlen);
m_dtms=new_m_dtms;
int new_m_dtm_offsets[] = new int[newlen];
System.arraycopy(m_dtm_offsets,0,new_m_dtm_offsets,0,oldlen);
m_dtm_offsets=new_m_dtm_offsets;
}
m_dtms[id] = dtm;
m_dtm_offsets[id]=offset;
dtm.documentRegistration();
// The DTM should have been told who its manager was when we created it.
// Do we need to allow for adopting DTMs _not_ created by this manager?
}
/**
* Get the first free DTM ID available. %OPT% Linear search is inefficient!
*/
synchronized public int getFirstFreeDTMID()
{
int n = m_dtms.length;
for (int i = 1; i < n; i++)
{
if(null == m_dtms[i])
{
return i;
}
}
return n; // count on addDTM() to throw exception if out of range
}
/**
* The default table for exandedNameID lookups.
*/
private ExpandedNameTable m_expandedNameTable =
new ExpandedNameTable();
/**
* Constructor DTMManagerDefault
*
*/
public DTMManagerDefault(){}
/**
* Get an instance of a DTM, loaded with the content from the
* specified source. If the unique flag is true, a new instance will
* always be returned. Otherwise it is up to the DTMManager to return a
* new instance or an instance that it already created and may be being used
* by someone else.
*
* A bit of magic in this implementation: If the source is null, unique is true,
* and incremental and doIndexing are both false, we return an instance of
* SAX2RTFDTM, which see.
*
* (I think more parameters will need to be added for error handling, and entity
* resolution, and more explicit control of the RTF situation).
*
* @param source the specification of the source object.
* @param unique true if the returned DTM must be unique, probably because it
* is going to be mutated.
* @param whiteSpaceFilter Enables filtering of whitespace nodes, and may
* be null.
* @param incremental true if the DTM should be built incrementally, if
* possible.
* @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
*
* @return a non-null DTM reference.
*/
synchronized public DTM getDTM(Source source, boolean unique,
DTMWSFilter whiteSpaceFilter,
boolean incremental, boolean doIndexing)
{
if(DEBUG && null != source)
System.out.println("Starting "+
(unique ? "UNIQUE" : "shared")+
" source: "+source.getSystemId()
);
XMLStringFactory xstringFactory = m_xsf;
int dtmPos = getFirstFreeDTMID();
int documentID = dtmPos << IDENT_DTM_NODE_BITS;
if ((null != source) && source instanceof DOMSource)
{
DOM2DTM dtm = new DOM2DTM(this, (DOMSource) source, documentID,
whiteSpaceFilter, xstringFactory, doIndexing);
addDTM(dtm, dtmPos, 0);
// if (DUMPTREE)
// {
// dtm.dumpDTM();
// }
return dtm;
}
else
{
boolean isSAXSource = (null != source)
? (source instanceof SAXSource) : true;
boolean isStreamSource = (null != source)
? (source instanceof StreamSource) : false;
if (isSAXSource || isStreamSource) {
XMLReader reader = null;
SAX2DTM dtm;
try {
InputSource xmlSource;
if (null == source) {
xmlSource = null;
} else {
reader = getXMLReader(source);
xmlSource = SAXSource.sourceToInputSource(source);
String urlOfSource = xmlSource.getSystemId();
if (null != urlOfSource) {
try {
urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
} catch (Exception e) {
// %REVIEW% Is there a better way to send a warning?
System.err.println("Can not absolutize URL: " + urlOfSource);
}
xmlSource.setSystemId(urlOfSource);
}
}
if (source==null && unique && !incremental && !doIndexing) {
// Special case to support RTF construction into shared DTM.
// It should actually still work for other uses,
// but may be slightly deoptimized relative to the base
// to allow it to deal with carrying multiple documents.
//
// %REVIEW% This is a sloppy way to request this mode;
// we need to consider architectural improvements.
dtm = new SAX2RTFDTM(this, source, documentID, whiteSpaceFilter,
xstringFactory, doIndexing);
}
/**************************************************************
// EXPERIMENTAL 3/22/02
else if(JKESS_XNI_EXPERIMENT && m_incremental) {
dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
xstringFactory, doIndexing);
}
**************************************************************/
// Create the basic SAX2DTM.
else {
dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
xstringFactory, doIndexing);
}
// Go ahead and add the DTM to the lookup table. This needs to be
// done before any parsing occurs. Note offset 0, since we've just
// created a new DTM.
addDTM(dtm, dtmPos, 0);
boolean haveXercesParser =
(null != reader)
&& (reader.getClass()
.getName()
.equals("com.sun.org.apache.xerces.internal.parsers.SAXParser") );
if (haveXercesParser) {
incremental = true; // No matter what. %REVIEW%
}
// If the reader is null, but they still requested an incremental
// build, then we still want to set up the IncrementalSAXSource stuff.
if (m_incremental && incremental
/* || ((null == reader) && incremental) */) {
IncrementalSAXSource coParser=null;
if (haveXercesParser) {
// IncrementalSAXSource_Xerces to avoid threading.
try {
coParser =(IncrementalSAXSource)
Class.forName("com.sun.org.apache.xml.internal.dtm.ref.IncrementalSAXSource_Xerces").newInstance();
} catch( Exception ex ) {
ex.printStackTrace();
coParser=null;
}
}
if (coParser==null ) {
// Create a IncrementalSAXSource to run on the secondary thread.
if (null == reader) {
coParser = new IncrementalSAXSource_Filter();
} else {
IncrementalSAXSource_Filter filter =
new IncrementalSAXSource_Filter();
filter.setXMLReader(reader);
coParser=filter;
}
}
/**************************************************************
// EXPERIMENTAL 3/22/02
if (JKESS_XNI_EXPERIMENT && m_incremental &&
dtm instanceof XNI2DTM &&
coParser instanceof IncrementalSAXSource_Xerces) {
com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration xpc=
((IncrementalSAXSource_Xerces)coParser)
.getXNIParserConfiguration();
if (xpc!=null) {
// Bypass SAX; listen to the XNI stream
((XNI2DTM)dtm).setIncrementalXNISource(xpc);
} else {
// Listen to the SAX stream (will fail, diagnostically...)
dtm.setIncrementalSAXSource(coParser);
}
} else
***************************************************************/
// Have the DTM set itself up as IncrementalSAXSource's listener.
dtm.setIncrementalSAXSource(coParser);
if (null == xmlSource) {
// Then the user will construct it themselves.
return dtm;
}
if (null == reader.getErrorHandler()) {
reader.setErrorHandler(dtm);
}
reader.setDTDHandler(dtm);
try {
// Launch parsing coroutine. Launches a second thread,
// if we're using IncrementalSAXSource.filter().
coParser.startParse(xmlSource);
} catch (RuntimeException re) {
dtm.clearCoRoutine();
throw re;
} catch (Exception e) {
dtm.clearCoRoutine();
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
}
} else {
if (null == reader) {
// Then the user will construct it themselves.
return dtm;
}
// not incremental
reader.setContentHandler(dtm);
reader.setDTDHandler(dtm);
if (null == reader.getErrorHandler()) {
reader.setErrorHandler(dtm);
}
try {
reader.setProperty(
"http://xml.org/sax/properties/lexical-handler",
dtm);
} catch (SAXNotRecognizedException e){}
catch (SAXNotSupportedException e){}
try {
reader.parse(xmlSource);
} catch (RuntimeException re) {
dtm.clearCoRoutine();
throw re;
} catch (Exception e) {
dtm.clearCoRoutine();
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
}
}
if (DUMPTREE) {
System.out.println("Dumping SAX2DOM");
dtm.dumpDTM(System.err);
}
return dtm;
} finally {
// Reset the ContentHandler, DTDHandler, ErrorHandler to the DefaultHandler
// after creating the DTM.
if (reader != null && !(m_incremental && incremental)) {
reader.setContentHandler(m_defaultHandler);
reader.setDTDHandler(m_defaultHandler);
reader.setErrorHandler(m_defaultHandler);
// Reset the LexicalHandler to null after creating the DTM.
try {
reader.setProperty("http://xml.org/sax/properties/lexical-handler", null);
}
catch (Exception e) {}
}
releaseXMLReader(reader);
}
} else {
// It should have been handled by a derived class or the caller
// made a mistake.
throw new DTMException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NOT_SUPPORTED, new Object[]{source})); //"Not supported: " + source);
}
}
}
/**
* Given a W3C DOM node, try and return a DTM handle.
* Note: calling this may be non-optimal, and there is no guarantee that
* the node will be found in any particular DTM.
*
* @param node Non-null reference to a DOM node.
*
* @return a valid DTM handle.
*/
synchronized public int getDTMHandleFromNode(org.w3c.dom.Node node)
{
if(null == node)
throw new IllegalArgumentException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NODE_NON_NULL, null)); //"node must be non-null for getDTMHandleFromNode!");
if (node instanceof com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy)
return ((com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy) node).getDTMNodeNumber();
else
{
// Find the DOM2DTMs wrapped around this Document (if any)
// and check whether they contain the Node in question.
//
// NOTE that since a DOM2DTM may represent a subtree rather
// than a full document, we have to be prepared to check more
// than one -- and there is no guarantee that we will find
// one that contains ancestors or siblings of the node we're
// seeking.
//
// %REVIEW% We could search for the one which contains this
// node at the deepest level, and thus covers the widest
// subtree, but that's going to entail additional work
// checking more DTMs... and getHandleOfNode is not a
// cheap operation in most implementations.
//
// TODO: %REVIEW% If overflow addressing, we may recheck a DTM
// already examined. Ouch. But with the increased number of DTMs,
// scanning back to check this is painful.
// POSSIBLE SOLUTIONS:
// Generate a list of _unique_ DTM objects?
// Have each DTM cache last DOM node search?
int max = m_dtms.length;
for(int i = 0; i < max; i++)
{
DTM thisDTM=m_dtms[i];
if((null != thisDTM) && thisDTM instanceof DOM2DTM)
{
int handle=((DOM2DTM)thisDTM).getHandleOfNode(node);
if(handle!=DTM.NULL) return handle;
}
}
// Not found; generate a new DTM.
//
// %REVIEW% Is this really desirable, or should we return null
// and make folks explicitly instantiate from a DOMSource? The
// latter is more work but gives the caller the opportunity to
// explicitly add the DTM to a DTMManager... and thus to know when
// it can be discarded again, which is something we need to pay much
// more attention to. (Especially since only DTMs which are assigned
// to a manager can use the overflow addressing scheme.)
//
// %BUG% If the source node was a DOM2DTM$defaultNamespaceDeclarationNode
// and the DTM wasn't registered with this DTMManager, we will create
// a new DTM and _still_ not be able to find the node (since it will
// be resynthesized). Another reason to push hard on making all DTMs
// be managed DTMs.
// Since the real root of our tree may be a DocumentFragment, we need to
// use getParent to find the root, instead of getOwnerDocument. Otherwise
// DOM2DTM#getHandleOfNode will be very unhappy.
Node root = node;
Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
for (; p != null; p = p.getParentNode())
{
root = p;
}
DOM2DTM dtm = (DOM2DTM) getDTM(new javax.xml.transform.dom.DOMSource(root),
false, null, true, true);
int handle;
if(node instanceof com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode)
{
// Can't return the same node since it's unique to a specific DTM,
// but can return the equivalent node -- find the corresponding
// Document Element, then ask it for the xml: namespace decl.
handle=dtm.getHandleOfNode(((org.w3c.dom.Attr)node).getOwnerElement());
handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
}
else
handle = ((DOM2DTM)dtm).getHandleOfNode(node);
if(DTM.NULL == handle)
throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COULD_NOT_RESOLVE_NODE, null)); //"Could not resolve the node to a handle!");
return handle;
}
}
/**
* This method returns the SAX2 parser to use with the InputSource
* obtained from this URI.
* It may return null if any SAX2-conformant XML parser can be used,
* or if getInputSource() will also return null. The parser must
* be free for use (i.e., not currently in use for another parse().
* After use of the parser is completed, the releaseXMLReader(XMLReader)
* must be called.
*
* @param inputSource The value returned from the URIResolver.
* @return a SAX2 XMLReader to use to resolve the inputSource argument.
*
* @return non-null XMLReader reference ready to parse.
*/
synchronized public XMLReader getXMLReader(Source inputSource)
{
try
{
XMLReader reader = (inputSource instanceof SAXSource)
? ((SAXSource) inputSource).getXMLReader() : null;
// If user did not supply a reader, ask for one from the reader manager
if (null == reader) {
if (m_readerManager == null) {
m_readerManager = XMLReaderManager.getInstance(super.overrideDefaultParser());
}
reader = m_readerManager.getXMLReader();
}
return reader;
} catch (SAXException se) {
throw new DTMException(se.getMessage(), se);
}
}
/**
* Indicates that the XMLReader object is no longer in use for the transform.
*
* Note that the getXMLReader method may return an XMLReader that was
* specified on the SAXSource object by the application code. Such a
* reader should still be passed to releaseXMLReader, but the reader manager
* will only re-use XMLReaders that it created.
*
* @param reader The XMLReader to be released.
*/
synchronized public void releaseXMLReader(XMLReader reader) {
if (m_readerManager != null) {
m_readerManager.releaseXMLReader(reader);
}
}
/**
* Return the DTM object containing a representation of this node.
*
* @param nodeHandle DTM Handle indicating which node to retrieve
*
* @return a reference to the DTM object containing this node.
*/
synchronized public DTM getDTM(int nodeHandle)
{
try
{
// Performance critical function.
return m_dtms[nodeHandle >>> IDENT_DTM_NODE_BITS];
}
catch(java.lang.ArrayIndexOutOfBoundsException e)
{
if(nodeHandle==DTM.NULL)
return null; // Accept as a special case.
else
throw e; // Programming error; want to know about it.
}
}
/**
* Given a DTM, find the ID number in the DTM tables which addresses
* the start of the document. If overflow addressing is in use, other
* DTM IDs may also be assigned to this DTM.
*
* @param dtm The DTM which (hopefully) contains this node.
*
* @return The DTM ID (as the high bits of a NodeHandle, not as our
* internal index), or -1 if the DTM doesn't belong to this manager.
*/
synchronized public int getDTMIdentity(DTM dtm)
{
// Shortcut using DTMDefaultBase's extension hooks
// %REVIEW% Should the lookup be part of the basic DTM API?
if(dtm instanceof DTMDefaultBase)
{
DTMDefaultBase dtmdb=(DTMDefaultBase)dtm;
if(dtmdb.getManager()==this)
return dtmdb.getDTMIDs().elementAt(0);
else
return -1;
}
int n = m_dtms.length;
for (int i = 0; i < n; i++)
{
DTM tdtm = m_dtms[i];
if (tdtm == dtm && m_dtm_offsets[i]==0)
return i << IDENT_DTM_NODE_BITS;
}
return -1;
}
/**
* Release the DTMManager's reference(s) to a DTM, making it unmanaged.
* This is typically done as part of returning the DTM to the heap after
* we're done with it.
*
* @param dtm the DTM to be released.
*
* @param shouldHardDelete If false, this call is a suggestion rather than an
* order, and we may not actually release the DTM. This is intended to
* support intelligent caching of documents... which is not implemented
* in this version of the DTM manager.
*
* @return true if the DTM was released, false if shouldHardDelete was set
* and we decided not to.
*/
synchronized public boolean release(DTM dtm, boolean shouldHardDelete)
{
if(DEBUG)
{
System.out.println("Releasing "+
(shouldHardDelete ? "HARD" : "soft")+
" dtm="+
// Following shouldn't need a nodeHandle, but does...
// and doesn't seem to report the intended value
dtm.getDocumentBaseURI()
);
}
if (dtm instanceof SAX2DTM)
{
((SAX2DTM) dtm).clearCoRoutine();
}
// Multiple DTM IDs may be assigned to a single DTM.
// The Right Answer is to ask which (if it supports
// extension, the DTM will need a list anyway). The
// Wrong Answer, applied if the DTM can't help us,
// is to linearly search them all; this may be very
// painful.
//
// %REVIEW% Should the lookup move up into the basic DTM API?
if(dtm instanceof DTMDefaultBase)
{
com.sun.org.apache.xml.internal.utils.SuballocatedIntVector ids=((DTMDefaultBase)dtm).getDTMIDs();
for(int i=ids.size()-1;i>=0;--i)
m_dtms[ids.elementAt(i)>>>DTMManager.IDENT_DTM_NODE_BITS]=null;
}
else
{
int i = getDTMIdentity(dtm);
if (i >= 0)
{
m_dtms[i >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
}
}
dtm.documentRelease();
return true;
}
/**
* Method createDocumentFragment
*
*
* NEEDSDOC (createDocumentFragment) @return
*/
synchronized public DTM createDocumentFragment()
{
try
{
DocumentBuilderFactory dbf = JdkXmlUtils.getDOMFactory(super.overrideDefaultParser());
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();
Node df = doc.createDocumentFragment();
return getDTM(new DOMSource(df), true, null, false, false);
}
catch (Exception e)
{
throw new DTMException(e);
}
}
/**
* NEEDSDOC Method createDTMIterator
*
*
* NEEDSDOC @param whatToShow
* NEEDSDOC @param filter
* NEEDSDOC @param entityReferenceExpansion
*
* NEEDSDOC (createDTMIterator) @return
*/
synchronized public DTMIterator createDTMIterator(int whatToShow, DTMFilter filter,
boolean entityReferenceExpansion)
{
/** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMManager abstract method */
return null;
}
/**
* NEEDSDOC Method createDTMIterator
*
*
* NEEDSDOC @param xpathString
* NEEDSDOC @param presolver
*
* NEEDSDOC (createDTMIterator) @return
*/
synchronized public DTMIterator createDTMIterator(String xpathString,
PrefixResolver presolver)
{
/** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMManager abstract method */
return null;
}
/**
* NEEDSDOC Method createDTMIterator
*
*
* NEEDSDOC @param node
*
* NEEDSDOC (createDTMIterator) @return
*/
synchronized public DTMIterator createDTMIterator(int node)
{
/** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMManager abstract method */
return null;
}
/**
* NEEDSDOC Method createDTMIterator
*
*
* NEEDSDOC @param xpathCompiler
* NEEDSDOC @param pos
*
* NEEDSDOC (createDTMIterator) @return
*/
synchronized public DTMIterator createDTMIterator(Object xpathCompiler, int pos)
{
/** @todo: implement this com.sun.org.apache.xml.internal.dtm.DTMManager abstract method */
return null;
}
/**
* return the expanded name table.
*
* NEEDSDOC @param dtm
*
* NEEDSDOC ($objectName$) @return
*/
public ExpandedNameTable getExpandedNameTable(DTM dtm)
{
return m_expandedNameTable;
}
}

View File

@@ -0,0 +1,301 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
* DTMNamedNodeMap is a quickie (as opposed to quick) implementation of the DOM's
* NamedNodeMap interface, intended to support DTMProxy's getAttributes()
* call.
* <p>
* ***** Note: this does _not_ current attempt to cache any of the data;
* if you ask for attribute 27 and then 28, you'll have to rescan the first
* 27. It should probably at least keep track of the last one retrieved,
* and possibly buffer the whole array.
* <p>
* ***** Also note that there's no fastpath for the by-name query; we search
* linearly until we find it or fail to find it. Again, that could be
* optimized at some cost in object creation/storage.
* @xsl.usage internal
*/
public class DTMNamedNodeMap implements NamedNodeMap
{
/** The DTM for this node. */
DTM dtm;
/** The DTM element handle. */
int element;
/** The number of nodes in this map. */
short m_count = -1;
/**
* Create a getAttributes NamedNodeMap for a given DTM element node
*
* @param dtm The DTM Reference, must be non-null.
* @param element The DTM element handle.
*/
public DTMNamedNodeMap(DTM dtm, int element)
{
this.dtm = dtm;
this.element = element;
}
/**
* Return the number of Attributes on this Element
*
* @return The number of nodes in this map.
*/
public int getLength()
{
if (m_count == -1)
{
short count = 0;
for (int n = dtm.getFirstAttribute(element); n != -1;
n = dtm.getNextAttribute(n))
{
++count;
}
m_count = count;
}
return (int) m_count;
}
/**
* Retrieves a node specified by name.
* @param name The <code>nodeName</code> of a node to retrieve.
* @return A <code>Node</code> (of any type) with the specified
* <code>nodeName</code>, or <code>null</code> if it does not identify
* any node in this map.
*/
public Node getNamedItem(String name)
{
for (int n = dtm.getFirstAttribute(element); n != DTM.NULL;
n = dtm.getNextAttribute(n))
{
if (dtm.getNodeName(n).equals(name))
return dtm.getNode(n);
}
return null;
}
/**
* Returns the <code>index</code>th item in the map. If <code>index</code>
* is greater than or equal to the number of nodes in this map, this
* returns <code>null</code>.
* @param i The index of the requested item.
* @return The node at the <code>index</code>th position in the map, or
* <code>null</code> if that is not a valid index.
*/
public Node item(int i)
{
int count = 0;
for (int n = dtm.getFirstAttribute(element); n != -1;
n = dtm.getNextAttribute(n))
{
if (count == i)
return dtm.getNode(n);
else
++count;
}
return null;
}
/**
* Adds a node using its <code>nodeName</code> attribute. If a node with
* that name is already present in this map, it is replaced by the new
* one.
* <br>As the <code>nodeName</code> attribute is used to derive the name
* which the node must be stored under, multiple nodes of certain types
* (those that have a "special" string value) cannot be stored as the
* names would clash. This is seen as preferable to allowing nodes to be
* aliased.
* @param newNode node to store in this map. The node will later be
* accessible using the value of its <code>nodeName</code> attribute.
*
* @return If the new <code>Node</code> replaces an existing node the
* replaced <code>Node</code> is returned, otherwise <code>null</code>
* is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
* different document than the one that created this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
* <code>Attr</code> that is already an attribute of another
* <code>Element</code> object. The DOM user must explicitly clone
* <code>Attr</code> nodes to re-use them in other elements.
*/
public Node setNamedItem(Node newNode)
{
throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
}
/**
* Removes a node specified by name. When this map contains the attributes
* attached to an element, if the removed attribute is known to have a
* default value, an attribute immediately appears containing the
* default value as well as the corresponding namespace URI, local name,
* and prefix when applicable.
* @param name The <code>nodeName</code> of the node to remove.
*
* @return The node removed from this map if a node with such a name
* exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
* this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
*/
public Node removeNamedItem(String name)
{
throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
}
/**
* Retrieves a node specified by local name and namespace URI. HTML-only
* DOM implementations do not need to implement this method.
* @param namespaceURI The namespace URI of the node to retrieve.
* @param localName The local name of the node to retrieve.
*
* @return A <code>Node</code> (of any type) with the specified local
* name and namespace URI, or <code>null</code> if they do not
* identify any node in this map.
* @since DOM Level 2
*/
public Node getNamedItemNS(String namespaceURI, String localName)
{
Node retNode = null;
for (int n = dtm.getFirstAttribute(element); n != DTM.NULL;
n = dtm.getNextAttribute(n))
{
if (localName.equals(dtm.getLocalName(n)))
{
String nsURI = dtm.getNamespaceURI(n);
if ((namespaceURI == null && nsURI == null)
|| (namespaceURI != null && namespaceURI.equals(nsURI)))
{
retNode = dtm.getNode(n);
break;
}
}
}
return retNode;
}
/**
* Adds a node using its <code>namespaceURI</code> and
* <code>localName</code>. If a node with that namespace URI and that
* local name is already present in this map, it is replaced by the new
* one.
* <br>HTML-only DOM implementations do not need to implement this method.
* @param arg A node to store in this map. The node will later be
* accessible using the value of its <code>namespaceURI</code> and
* <code>localName</code> attributes.
*
* @return If the new <code>Node</code> replaces an existing node the
* replaced <code>Node</code> is returned, otherwise <code>null</code>
* is returned.
* @exception DOMException
* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
* different document than the one that created this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
* <code>Attr</code> that is already an attribute of another
* <code>Element</code> object. The DOM user must explicitly clone
* <code>Attr</code> nodes to re-use them in other elements.
* @since DOM Level 2
*/
public Node setNamedItemNS(Node arg) throws DOMException
{
throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
}
/**
* Removes a node specified by local name and namespace URI. A removed
* attribute may be known to have a default value when this map contains
* the attributes attached to an element, as returned by the attributes
* attribute of the <code>Node</code> interface. If so, an attribute
* immediately appears containing the default value as well as the
* corresponding namespace URI, local name, and prefix when applicable.
* <br>HTML-only DOM implementations do not need to implement this method.
*
* @param namespaceURI The namespace URI of the node to remove.
* @param localName The local name of the node to remove.
*
* @return The node removed from this map if a node with such a local
* name and namespace URI exists.
* @exception DOMException
* NOT_FOUND_ERR: Raised if there is no node with the specified
* <code>namespaceURI</code> and <code>localName</code> in this map.
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
* @since DOM Level 2
*/
public Node removeNamedItemNS(String namespaceURI, String localName)
throws DOMException
{
throw new DTMException(DTMException.NO_MODIFICATION_ALLOWED_ERR);
}
/**
* Simple implementation of DOMException.
* @xsl.usage internal
*/
public class DTMException extends org.w3c.dom.DOMException
{
static final long serialVersionUID = -8290238117162437678L;
/**
* Constructs a DOM/DTM exception.
*
* @param code
* @param message
*/
public DTMException(short code, String message)
{
super(code, message);
}
/**
* Constructor DTMException
*
*
* @param code
*/
public DTMException(short code)
{
super(code, "");
}
}
}

View File

@@ -0,0 +1,187 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMDOMException;
import com.sun.org.apache.xml.internal.dtm.DTMIterator;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.NodeFilter;
/**
* <code>DTMNodeIterator</code> gives us an implementation of the
* DTMNodeIterator which returns DOM nodes.
*
* Please note that this is not necessarily equivlaent to a DOM
* NodeIterator operating over the same document. In particular:
* <ul>
*
* <li>If there are several Text nodes in logical succession (ie,
* across CDATASection and EntityReference boundaries), we will return
* only the first; the caller is responsible for stepping through
* them.
* (%REVIEW% Provide a convenience routine here to assist, pending
* proposed DOM Level 3 getAdjacentText() operation?) </li>
*
* <li>Since the whole XPath/XSLT architecture assumes that the source
* document is not altered while we're working with it, we do not
* promise to implement the DOM NodeIterator's "maintain current
* position" response to document mutation. </li>
*
* <li>Since our design for XPath NodeIterators builds a stateful
* filter directly into the traversal object, getNodeFilter() is not
* supported.</li>
*
* </ul>
*
* <p>State: In progress!!</p>
* */
public class DTMNodeIterator implements org.w3c.dom.traversal.NodeIterator
{
private DTMIterator dtm_iter;
private boolean valid=true;
//================================================================
// Methods unique to this class
/** Public constructor: Wrap a DTMNodeIterator around an existing
* and preconfigured DTMIterator
* */
public DTMNodeIterator(DTMIterator dtmIterator)
{
try
{
dtm_iter=(DTMIterator)dtmIterator.clone();
}
catch(CloneNotSupportedException cnse)
{
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(cnse);
}
}
/** Access the wrapped DTMIterator. I'm not sure whether anyone will
* need this or not, but let's write it and think about it.
* */
public DTMIterator getDTMIterator()
{
return dtm_iter;
}
//================================================================
// org.w3c.dom.traversal.NodeFilter API follows
/** Detaches the NodeIterator from the set which it iterated over,
* releasing any computational resources and placing the iterator in
* the INVALID state.
* */
public void detach()
{
// Theoretically, we could release dtm_iter at this point. But
// some of the operations may still want to consult it even though
// navigation is now invalid.
valid=false;
}
/** The value of this flag determines whether the children
* of entity reference nodes are visible to the iterator.
*
* @return false, always (the DTM model flattens entity references)
* */
public boolean getExpandEntityReferences()
{
return false;
}
/** Return a handle to the filter used to screen nodes.
*
* This is ill-defined in Xalan's usage of Nodeiterator, where we have
* built stateful XPath-based filtering directly into the traversal
* object. We could return something which supports the NodeFilter interface
* and allows querying whether a given node would be permitted if it appeared
* as our next node, but in the current implementation that would be very
* complex -- and just isn't all that useful.
*
* @throws DOMException -- NOT_SUPPORTED_ERROR because I can't think
* of anything more useful to do in this case
* */
public NodeFilter getFilter()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
/** @return The root node of the NodeIterator, as specified
* when it was created.
* */
public Node getRoot()
{
int handle=dtm_iter.getRoot();
return dtm_iter.getDTM(handle).getNode(handle);
}
/** Return a mask describing which node types are presented via the
* iterator.
**/
public int getWhatToShow()
{
return dtm_iter.getWhatToShow();
}
/** @return the next node in the set and advance the position of the
* iterator in the set.
*
* @throws DOMException - INVALID_STATE_ERR Raised if this method is
* called after the detach method was invoked.
* */
public Node nextNode() throws DOMException
{
if(!valid)
throw new DTMDOMException(DOMException.INVALID_STATE_ERR);
int handle=dtm_iter.nextNode();
if (handle==DTM.NULL)
return null;
return dtm_iter.getDTM(handle).getNode(handle);
}
/** @return the next previous in the set and advance the position of the
* iterator in the set.
*
* @throws DOMException - INVALID_STATE_ERR Raised if this method is
* called after the detach method was invoked.
* */
public Node previousNode()
{
if(!valid)
throw new DTMDOMException(DOMException.INVALID_STATE_ERR);
int handle=dtm_iter.previousNode();
if (handle==DTM.NULL)
return null;
return dtm_iter.getDTM(handle).getNode(handle);
}
}

View File

@@ -0,0 +1,128 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMIterator;
import org.w3c.dom.Node;
/**
* <code>DTMNodeList</code> gives us an implementation of the DOM's
* NodeList interface wrapped around a DTM Iterator. The author
* considers this something of an abominations, since NodeList was not
* intended to be a general purpose "list of nodes" API and is
* generally considered by the DOM WG to have be a mistake... but I'm
* told that some of the XPath/XSLT folks say they must have this
* solution.
*
* Please note that this is not necessarily equivlaent to a DOM
* NodeList operating over the same document. In particular:
* <ul>
*
* <li>If there are several Text nodes in logical succession (ie,
* across CDATASection and EntityReference boundaries), we will return
* only the first; the caller is responsible for stepping through
* them.
* (%REVIEW% Provide a convenience routine here to assist, pending
* proposed DOM Level 3 getAdjacentText() operation?) </li>
*
* <li>Since the whole XPath/XSLT architecture assumes that the source
* document is not altered while we're working with it, we do not
* promise to implement the DOM NodeList's "live view" response to
* document mutation. </li>
*
* </ul>
*
* <p>State: In progress!!</p>
* */
public class DTMNodeList extends DTMNodeListBase {
private DTMIterator m_iter;
//================================================================
// Methods unique to this class
private DTMNodeList() {
}
/**
* Public constructor: Wrap a DTMNodeList around an existing
* and preconfigured DTMIterator
*
* WARNING: THIS HAS THE SIDE EFFECT OF ISSUING setShouldCacheNodes(true)
* AGAINST THE DTMIterator.
*
*/
public DTMNodeList(DTMIterator dtmIterator) {
if (dtmIterator != null) {
int pos = dtmIterator.getCurrentPos();
try {
m_iter=(DTMIterator)dtmIterator.cloneWithReset();
} catch(CloneNotSupportedException cnse) {
m_iter = dtmIterator;
}
m_iter.setShouldCacheNodes(true);
m_iter.runTo(-1);
m_iter.setCurrentPos(pos);
}
}
/**
* Access the wrapped DTMIterator. I'm not sure whether anyone will
* need this or not, but let's write it and think about it.
*
*/
public DTMIterator getDTMIterator() {
return m_iter;
}
//================================================================
// org.w3c.dom.NodeList API follows
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
public Node item(int index)
{
if (m_iter != null) {
int handle=m_iter.item(index);
if (handle == DTM.NULL) {
return null;
}
return m_iter.getDTM(handle).getNode(handle);
} else {
return null;
}
}
/**
* The number of nodes in the list. The range of valid child node indices
* is 0 to <code>length-1</code> inclusive.
*/
public int getLength() {
return (m_iter != null) ? m_iter.getLength() : 0;
}
}

View File

@@ -0,0 +1,82 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import org.w3c.dom.Node;
/**
* <code>DTMNodeList</code> gives us an implementation of the DOM's
* NodeList interface wrapped around a DTM Iterator. The author
* considers this something of an abominations, since NodeList was not
* intended to be a general purpose "list of nodes" API and is
* generally considered by the DOM WG to have be a mistake... but I'm
* told that some of the XPath/XSLT folks say they must have this
* solution.
*
* Please note that this is not necessarily equivlaent to a DOM
* NodeList operating over the same document. In particular:
* <ul>
*
* <li>If there are several Text nodes in logical succession (ie,
* across CDATASection and EntityReference boundaries), we will return
* only the first; the caller is responsible for stepping through
* them.
* (%REVIEW% Provide a convenience routine here to assist, pending
* proposed DOM Level 3 getAdjacentText() operation?) </li>
*
* <li>Since the whole XPath/XSLT architecture assumes that the source
* document is not altered while we're working with it, we do not
* promise to implement the DOM NodeList's "live view" response to
* document mutation. </li>
*
* </ul>
*
* <p>State: In progress!!</p>
*
*/
public class DTMNodeListBase implements org.w3c.dom.NodeList {
public DTMNodeListBase() {
}
//================================================================
// org.w3c.dom.NodeList API follows
/**
* Returns the <code>index</code>th item in the collection. If
* <code>index</code> is greater than or equal to the number of nodes in
* the list, this returns <code>null</code>.
* @param index Index into the collection.
* @return The node at the <code>index</code>th position in the
* <code>NodeList</code>, or <code>null</code> if that is not a valid
* index.
*/
public Node item(int index) {
return null;
}
/**
* The number of nodes in the list. The range of valid child node indices
* is 0 to <code>length-1</code> inclusive.
*/
public int getLength() {
return 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
/** <p>Like DTMStringPool, but threadsafe. It's been proposed that DTMs
* share their string pool(s); that raises threadsafety issues which
* this addresses. Of course performance is inferior to that of the
* bare-bones version.</p>
*
* <p>Status: Passed basic test in main().</p>
* */
public class DTMSafeStringPool
extends DTMStringPool
{
public synchronized void removeAllElements()
{
super.removeAllElements();
}
/** @return string whose value is uniquely identified by this integer index.
* @throws java.lang.ArrayIndexOutOfBoundsException
* if index doesn't map to a string.
* */
public synchronized String indexToString(int i)
throws java.lang.ArrayIndexOutOfBoundsException
{
return super.indexToString(i);
}
/** @return integer index uniquely identifying the value of this string. */
public synchronized int stringToIndex(String s)
{
return super.stringToIndex(s);
}
/** Command-line unit test driver. This test relies on the fact that
* this version of the pool assigns indices consecutively, starting
* from zero, as new unique strings are encountered.
*/
public static void _main(String[] args)
{
String[] word={
"Zero","One","Two","Three","Four","Five",
"Six","Seven","Eight","Nine","Ten",
"Eleven","Twelve","Thirteen","Fourteen","Fifteen",
"Sixteen","Seventeen","Eighteen","Nineteen","Twenty",
"Twenty-One","Twenty-Two","Twenty-Three","Twenty-Four",
"Twenty-Five","Twenty-Six","Twenty-Seven","Twenty-Eight",
"Twenty-Nine","Thirty","Thirty-One","Thirty-Two",
"Thirty-Three","Thirty-Four","Thirty-Five","Thirty-Six",
"Thirty-Seven","Thirty-Eight","Thirty-Nine"};
DTMStringPool pool=new DTMSafeStringPool();
System.out.println("If no complaints are printed below, we passed initial test.");
for(int pass=0;pass<=1;++pass)
{
int i;
for(i=0;i<word.length;++i)
{
int j=pool.stringToIndex(word[i]);
if(j!=i)
System.out.println("\tMismatch populating pool: assigned "+
j+" for create "+i);
}
for(i=0;i<word.length;++i)
{
int j=pool.stringToIndex(word[i]);
if(j!=i)
System.out.println("\tMismatch in stringToIndex: returned "+
j+" for lookup "+i);
}
for(i=0;i<word.length;++i)
{
String w=pool.indexToString(i);
if(!word[i].equals(w))
System.out.println("\tMismatch in indexToString: returned"+
w+" for lookup "+i);
}
pool.removeAllElements();
System.out.println("\nPass "+pass+" complete\n");
} // end pass loop
}
} // DTMSafeStringPool

View File

@@ -0,0 +1,191 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import java.util.Vector;
import com.sun.org.apache.xml.internal.utils.IntVector;
/** <p>DTMStringPool is an "interning" mechanism for strings. It will
* create a stable 1:1 mapping between a set of string values and a set of
* integer index values, so the integers can be used to reliably and
* uniquely identify (and when necessary retrieve) the strings.</p>
*
* <p>Design Priorities:
* <ul>
* <li>String-to-index lookup speed is critical.</li>
* <li>Index-to-String lookup speed is slightly less so.</li>
* <li>Threadsafety is not guaranteed at this level.
* Enforce that in the application if needed.</li>
* <li>Storage efficiency is an issue but not a huge one.
* It is expected that string pools won't exceed about 2000 entries.</li>
* </ul>
* </p>
*
* <p>Implementation detail: A standard Hashtable is relatively
* inefficient when looking up primitive int values, especially when
* we're already maintaining an int-to-string vector. So I'm
* maintaining a simple hash chain within this class.</p>
*
* <p>NOTE: There is nothing in the code that has a real dependency upon
* String. It would work with any object type that implements reliable
* .hashCode() and .equals() operations. The API enforces Strings because
* it's safer that way, but this could trivially be turned into a general
* ObjectPool if one was needed.</p>
*
* <p>Status: Passed basic test in main().</p>
* */
public class DTMStringPool
{
Vector m_intToString;
static final int HASHPRIME=101;
int[] m_hashStart=new int[HASHPRIME];
IntVector m_hashChain;
public static final int NULL=-1;
/**
* Create a DTMStringPool using the given chain size
*
* @param chainSize The size of the hash chain vector
*/
public DTMStringPool(int chainSize)
{
m_intToString=new Vector();
m_hashChain=new IntVector(chainSize);
removeAllElements();
// -sb Add this to force empty strings to be index 0.
stringToIndex("");
}
public DTMStringPool()
{
this(512);
}
public void removeAllElements()
{
m_intToString.removeAllElements();
for(int i=0;i<HASHPRIME;++i)
m_hashStart[i]=NULL;
m_hashChain.removeAllElements();
}
/** @return string whose value is uniquely identified by this integer index.
* @throws java.lang.ArrayIndexOutOfBoundsException
* if index doesn't map to a string.
* */
public String indexToString(int i)
throws java.lang.ArrayIndexOutOfBoundsException
{
if(i==NULL) return null;
return (String) m_intToString.elementAt(i);
}
/** @return integer index uniquely identifying the value of this string. */
public int stringToIndex(String s)
{
if(s==null) return NULL;
int hashslot=s.hashCode()%HASHPRIME;
if(hashslot<0) hashslot=-hashslot;
// Is it one we already know?
int hashlast=m_hashStart[hashslot];
int hashcandidate=hashlast;
while(hashcandidate!=NULL)
{
if(m_intToString.elementAt(hashcandidate).equals(s))
return hashcandidate;
hashlast=hashcandidate;
hashcandidate=m_hashChain.elementAt(hashcandidate);
}
// New value. Add to tables.
int newIndex=m_intToString.size();
m_intToString.addElement(s);
m_hashChain.addElement(NULL); // Initialize to no-following-same-hash
if(hashlast==NULL) // First for this hash
m_hashStart[hashslot]=newIndex;
else // Link from previous with same hash
m_hashChain.setElementAt(newIndex,hashlast);
return newIndex;
}
/** Command-line unit test driver. This test relies on the fact that
* this version of the pool assigns indices consecutively, starting
* from zero, as new unique strings are encountered.
*/
public static void _main(String[] args)
{
String[] word={
"Zero","One","Two","Three","Four","Five",
"Six","Seven","Eight","Nine","Ten",
"Eleven","Twelve","Thirteen","Fourteen","Fifteen",
"Sixteen","Seventeen","Eighteen","Nineteen","Twenty",
"Twenty-One","Twenty-Two","Twenty-Three","Twenty-Four",
"Twenty-Five","Twenty-Six","Twenty-Seven","Twenty-Eight",
"Twenty-Nine","Thirty","Thirty-One","Thirty-Two",
"Thirty-Three","Thirty-Four","Thirty-Five","Thirty-Six",
"Thirty-Seven","Thirty-Eight","Thirty-Nine"};
DTMStringPool pool=new DTMStringPool();
System.out.println("If no complaints are printed below, we passed initial test.");
for(int pass=0;pass<=1;++pass)
{
int i;
for(i=0;i<word.length;++i)
{
int j=pool.stringToIndex(word[i]);
if(j!=i)
System.out.println("\tMismatch populating pool: assigned "+
j+" for create "+i);
}
for(i=0;i<word.length;++i)
{
int j=pool.stringToIndex(word[i]);
if(j!=i)
System.out.println("\tMismatch in stringToIndex: returned "+
j+" for lookup "+i);
}
for(i=0;i<word.length;++i)
{
String w=pool.indexToString(i);
if(!word[i].equals(w))
System.out.println("\tMismatch in indexToString: returned"+
w+" for lookup "+i);
}
pool.removeAllElements();
System.out.println("\nPass "+pass+" complete\n");
} // end pass loop
}
}

View File

@@ -0,0 +1,404 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.utils.NodeConsumer;
import com.sun.org.apache.xml.internal.utils.XMLString;
import org.xml.sax.ContentHandler;
import org.xml.sax.ext.LexicalHandler;
/**
* This class does a pre-order walk of the DTM tree, calling a ContentHandler
* interface as it goes. As such, it's more like the Visitor design pattern
* than like the DOM's TreeWalker.
*
* I think normally this class should not be needed, because
* of DTM#dispatchToEvents.
* @xsl.usage advanced
*/
public class DTMTreeWalker
{
/** Local reference to a ContentHandler */
private ContentHandler m_contentHandler = null;
/** DomHelper for this TreeWalker */
protected DTM m_dtm;
/**
* Set the DTM to be traversed.
*
* @param dtm The Document Table Model to be used.
*/
public void setDTM(DTM dtm)
{
m_dtm = dtm;
}
/**
* Get the ContentHandler used for the tree walk.
*
* @return the ContentHandler used for the tree walk
*/
public ContentHandler getcontentHandler()
{
return m_contentHandler;
}
/**
* Set the ContentHandler used for the tree walk.
*
* @param ch the ContentHandler to be the result of the tree walk.
*/
public void setcontentHandler(ContentHandler ch)
{
m_contentHandler = ch;
}
/**
* Constructor.
*/
public DTMTreeWalker()
{
}
/**
* Constructor.
* @param contentHandler The implemention of the
* contentHandler operation (toXMLString, digest, ...)
*/
public DTMTreeWalker(ContentHandler contentHandler, DTM dtm)
{
this.m_contentHandler = contentHandler;
m_dtm = dtm;
}
/** Perform a non-recursive pre-order/post-order traversal,
* operating as a Visitor. startNode (preorder) and endNode
* (postorder) are invoked for each node as we traverse over them,
* with the result that the node is written out to m_contentHandler.
*
* @param pos Node in the tree at which to start (and end) traversal --
* in other words, the root of the subtree to traverse over.
*
* @throws TransformerException */
public void traverse(int pos) throws org.xml.sax.SAXException
{
// %REVIEW% Why isn't this just traverse(pos,pos)?
int top = pos; // Remember the root of this subtree
while (DTM.NULL != pos)
{
startNode(pos);
int nextNode = m_dtm.getFirstChild(pos);
while (DTM.NULL == nextNode)
{
endNode(pos);
if (top == pos)
break;
nextNode = m_dtm.getNextSibling(pos);
if (DTM.NULL == nextNode)
{
pos = m_dtm.getParent(pos);
if ((DTM.NULL == pos) || (top == pos))
{
// %REVIEW% This condition isn't tested in traverse(pos,top)
// -- bug?
if (DTM.NULL != pos)
endNode(pos);
nextNode = DTM.NULL;
break;
}
}
}
pos = nextNode;
}
}
/** Perform a non-recursive pre-order/post-order traversal,
* operating as a Visitor. startNode (preorder) and endNode
* (postorder) are invoked for each node as we traverse over them,
* with the result that the node is written out to m_contentHandler.
*
* @param pos Node in the tree where to start traversal
* @param top Node in the tree where to end traversal.
* If top==DTM.NULL, run through end of document.
*
* @throws TransformerException
*/
public void traverse(int pos, int top) throws org.xml.sax.SAXException
{
// %OPT% Can we simplify the loop conditionals by adding:
// if(top==DTM.NULL) top=0
// -- or by simply ignoring this case and relying on the fact that
// pos will never equal DTM.NULL until we're ready to exit?
while (DTM.NULL != pos)
{
startNode(pos);
int nextNode = m_dtm.getFirstChild(pos);
while (DTM.NULL == nextNode)
{
endNode(pos);
if ((DTM.NULL != top) && top == pos)
break;
nextNode = m_dtm.getNextSibling(pos);
if (DTM.NULL == nextNode)
{
pos = m_dtm.getParent(pos);
if ((DTM.NULL == pos) || ((DTM.NULL != top) && (top == pos)))
{
nextNode = DTM.NULL;
break;
}
}
}
pos = nextNode;
}
}
/** Flag indicating whether following text to be processed is raw text */
boolean nextIsRaw = false;
/**
* Optimized dispatch of characters.
*/
private final void dispatachChars(int node)
throws org.xml.sax.SAXException
{
m_dtm.dispatchCharactersEvents(node, m_contentHandler, false);
}
/**
* Start processing given node
*
*
* @param node Node to process
*
* @throws org.xml.sax.SAXException
*/
protected void startNode(int node) throws org.xml.sax.SAXException
{
if (m_contentHandler instanceof NodeConsumer)
{
// %TBD%
// ((NodeConsumer) m_contentHandler).setOriginatingNode(node);
}
switch (m_dtm.getNodeType(node))
{
case DTM.COMMENT_NODE :
{
XMLString data = m_dtm.getStringValue(node);
if (m_contentHandler instanceof LexicalHandler)
{
LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
data.dispatchAsComment(lh);
}
}
break;
case DTM.DOCUMENT_FRAGMENT_NODE :
// ??;
break;
case DTM.DOCUMENT_NODE :
this.m_contentHandler.startDocument();
break;
case DTM.ELEMENT_NODE :
DTM dtm = m_dtm;
for (int nsn = dtm.getFirstNamespaceNode(node, true); DTM.NULL != nsn;
nsn = dtm.getNextNamespaceNode(node, nsn, true))
{
// String prefix = dtm.getPrefix(nsn);
String prefix = dtm.getNodeNameX(nsn);
this.m_contentHandler.startPrefixMapping(prefix, dtm.getNodeValue(nsn));
}
// System.out.println("m_dh.getNamespaceOfNode(node): "+m_dh.getNamespaceOfNode(node));
// System.out.println("m_dh.getLocalNameOfNode(node): "+m_dh.getLocalNameOfNode(node));
String ns = dtm.getNamespaceURI(node);
if(null == ns)
ns = "";
// %OPT% !!
org.xml.sax.helpers.AttributesImpl attrs =
new org.xml.sax.helpers.AttributesImpl();
for (int i = dtm.getFirstAttribute(node);
i != DTM.NULL;
i = dtm.getNextAttribute(i))
{
attrs.addAttribute(dtm.getNamespaceURI(i),
dtm.getLocalName(i),
dtm.getNodeName(i),
"CDATA",
dtm.getNodeValue(i));
}
this.m_contentHandler.startElement(ns,
m_dtm.getLocalName(node),
m_dtm.getNodeName(node),
attrs);
break;
case DTM.PROCESSING_INSTRUCTION_NODE :
{
String name = m_dtm.getNodeName(node);
// String data = pi.getData();
if (name.equals("xslt-next-is-raw"))
{
nextIsRaw = true;
}
else
{
this.m_contentHandler.processingInstruction(name,
m_dtm.getNodeValue(node));
}
}
break;
case DTM.CDATA_SECTION_NODE :
{
boolean isLexH = (m_contentHandler instanceof LexicalHandler);
LexicalHandler lh = isLexH
? ((LexicalHandler) this.m_contentHandler) : null;
if (isLexH)
{
lh.startCDATA();
}
dispatachChars(node);
{
if (isLexH)
{
lh.endCDATA();
}
}
}
break;
case DTM.TEXT_NODE :
{
if (nextIsRaw)
{
nextIsRaw = false;
m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
dispatachChars(node);
m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
}
else
{
dispatachChars(node);
}
}
break;
case DTM.ENTITY_REFERENCE_NODE :
{
if (m_contentHandler instanceof LexicalHandler)
{
((LexicalHandler) this.m_contentHandler).startEntity(
m_dtm.getNodeName(node));
}
else
{
// warning("Can not output entity to a pure SAX ContentHandler");
}
}
break;
default :
}
}
/**
* End processing of given node
*
*
* @param node Node we just finished processing
*
* @throws org.xml.sax.SAXException
*/
protected void endNode(int node) throws org.xml.sax.SAXException
{
switch (m_dtm.getNodeType(node))
{
case DTM.DOCUMENT_NODE :
this.m_contentHandler.endDocument();
break;
case DTM.ELEMENT_NODE :
String ns = m_dtm.getNamespaceURI(node);
if(null == ns)
ns = "";
this.m_contentHandler.endElement(ns,
m_dtm.getLocalName(node),
m_dtm.getNodeName(node));
for (int nsn = m_dtm.getFirstNamespaceNode(node, true); DTM.NULL != nsn;
nsn = m_dtm.getNextNamespaceNode(node, nsn, true))
{
// String prefix = m_dtm.getPrefix(nsn);
String prefix = m_dtm.getNodeNameX(nsn);
this.m_contentHandler.endPrefixMapping(prefix);
}
break;
case DTM.CDATA_SECTION_NODE :
break;
case DTM.ENTITY_REFERENCE_NODE :
{
if (m_contentHandler instanceof LexicalHandler)
{
LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
lh.endEntity(m_dtm.getNodeName(node));
}
}
break;
default :
}
}
} //TreeWalker

View File

@@ -0,0 +1,63 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.dtm.DTM;
/**
* DTM Empty Axis Iterator. The class is immutable
*/
public final class EmptyIterator implements DTMAxisIterator
{
private static final EmptyIterator INSTANCE = new EmptyIterator();
public static DTMAxisIterator getInstance() {return INSTANCE;}
private EmptyIterator(){}
public final int next(){ return END; }
public final DTMAxisIterator reset(){ return this; }
public final int getLast(){ return 0; }
public final int getPosition(){ return 1; }
public final void setMark(){}
public final void gotoMark(){}
public final DTMAxisIterator setStartNode(int node){ return this; }
public final int getStartNode(){ return END; }
public final boolean isReverse(){return false;}
public final DTMAxisIterator cloneIterator(){ return this; }
public final void setRestartable(boolean isRestartable) {}
public final int getNodeByPosition(int position){ return END; }
}

View File

@@ -0,0 +1,392 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import com.sun.org.apache.xml.internal.dtm.DTM;
/**
* This is a default implementation of a table that manages mappings from
* expanded names to expandedNameIDs.
*
* %OPT% The performance of the getExpandedTypeID() method is very important
* to DTM building. To get the best performance out of this class, we implement
* a simple hash algorithm directly into this class, instead of using the
* inefficient java.util.Hashtable. The code for the get and put operations
* are combined in getExpandedTypeID() method to share the same hash calculation
* code. We only need to implement the rehash() interface which is used to
* expand the hash table.
*/
public class ExpandedNameTable
{
/** Array of extended types for this document */
private ExtendedType[] m_extendedTypes;
/** The initial size of the m_extendedTypes array */
private static int m_initialSize = 128;
/** Next available extended type */
// %REVIEW% Since this is (should be) always equal
// to the length of m_extendedTypes, do we need this?
private int m_nextType;
// These are all the types prerotated, for caller convenience.
public static final int ELEMENT = ((int)DTM.ELEMENT_NODE) ;
public static final int ATTRIBUTE = ((int)DTM.ATTRIBUTE_NODE) ;
public static final int TEXT = ((int)DTM.TEXT_NODE) ;
public static final int CDATA_SECTION = ((int)DTM.CDATA_SECTION_NODE) ;
public static final int ENTITY_REFERENCE = ((int)DTM.ENTITY_REFERENCE_NODE) ;
public static final int ENTITY = ((int)DTM.ENTITY_NODE) ;
public static final int PROCESSING_INSTRUCTION = ((int)DTM.PROCESSING_INSTRUCTION_NODE) ;
public static final int COMMENT = ((int)DTM.COMMENT_NODE) ;
public static final int DOCUMENT = ((int)DTM.DOCUMENT_NODE) ;
public static final int DOCUMENT_TYPE = ((int)DTM.DOCUMENT_TYPE_NODE) ;
public static final int DOCUMENT_FRAGMENT =((int)DTM.DOCUMENT_FRAGMENT_NODE) ;
public static final int NOTATION = ((int)DTM.NOTATION_NODE) ;
public static final int NAMESPACE = ((int)DTM.NAMESPACE_NODE) ;
/** Workspace for lookup. NOT THREAD SAFE!
* */
ExtendedType hashET = new ExtendedType(-1, "", "");
/** The array to store the default extended types. */
private static ExtendedType[] m_defaultExtendedTypes;
/**
* The default load factor of the Hashtable.
* This is used to calcualte the threshold.
*/
private static float m_loadFactor = 0.75f;
/**
* The initial capacity of the hash table. Use a bigger number
* to avoid the cost of expanding the table.
*/
private static int m_initialCapacity = 203;
/**
* The capacity of the hash table, i.e. the size of the
* internal HashEntry array.
*/
private int m_capacity;
/**
* The threshold of the hash table, which is equal to capacity * loadFactor.
* If the number of entries in the hash table is bigger than the threshold,
* the hash table needs to be expanded.
*/
private int m_threshold;
/**
* The internal array to store the hash entries.
* Each array member is a slot for a hash bucket.
*/
private HashEntry[] m_table;
/**
* Init default values
*/
static {
m_defaultExtendedTypes = new ExtendedType[DTM.NTYPES];
for (int i = 0; i < DTM.NTYPES; i++)
{
m_defaultExtendedTypes[i] = new ExtendedType(i, "", "");
}
}
/**
* Create an expanded name table.
*/
public ExpandedNameTable()
{
m_capacity = m_initialCapacity;
m_threshold = (int)(m_capacity * m_loadFactor);
m_table = new HashEntry[m_capacity];
initExtendedTypes();
}
/**
* Initialize the vector of extended types with the
* basic DOM node types.
*/
private void initExtendedTypes()
{
m_extendedTypes = new ExtendedType[m_initialSize];
for (int i = 0; i < DTM.NTYPES; i++) {
m_extendedTypes[i] = m_defaultExtendedTypes[i];
m_table[i] = new HashEntry(m_defaultExtendedTypes[i], i, i, null);
}
m_nextType = DTM.NTYPES;
}
/**
* Given an expanded name represented by namespace, local name and node type,
* return an ID. If the expanded-name does not exist in the internal tables,
* the entry will be created, and the ID will be returned. Any additional
* nodes that are created that have this expanded name will use this ID.
*
* @param namespace The namespace
* @param localName The local name
* @param type The node type
*
* @return the expanded-name id of the node.
*/
public int getExpandedTypeID(String namespace, String localName, int type)
{
return getExpandedTypeID(namespace, localName, type, false);
}
/**
* Given an expanded name represented by namespace, local name and node type,
* return an ID. If the expanded-name does not exist in the internal tables,
* the entry will be created, and the ID will be returned. Any additional
* nodes that are created that have this expanded name will use this ID.
* <p>
* If searchOnly is true, we will return -1 if the name is not found in the
* table, otherwise the name is added to the table and the expanded name id
* of the new entry is returned.
*
* @param namespace The namespace
* @param localName The local name
* @param type The node type
* @param searchOnly If it is true, we will only search for the expanded name.
* -1 is return is the name is not found.
*
* @return the expanded-name id of the node.
*/
public int getExpandedTypeID(String namespace, String localName, int type, boolean searchOnly)
{
if (null == namespace)
namespace = "";
if (null == localName)
localName = "";
// Calculate the hash code
int hash = type + namespace.hashCode() + localName.hashCode();
// Redefine the hashET object to represent the new expanded name.
hashET.redefine(type, namespace, localName, hash);
// Calculate the index into the HashEntry table.
int index = hash % m_capacity;
if (index < 0)
index = -index;
// Look up the expanded name in the hash table. Return the id if
// the expanded name is already in the hash table.
for (HashEntry e = m_table[index]; e != null; e = e.next)
{
if (e.hash == hash && e.key.equals(hashET))
return e.value;
}
if (searchOnly)
{
return DTM.NULL;
}
// Expand the internal HashEntry array if necessary.
if (m_nextType > m_threshold) {
rehash();
index = hash % m_capacity;
if (index < 0)
index = -index;
}
// Create a new ExtendedType object
ExtendedType newET = new ExtendedType(type, namespace, localName, hash);
// Expand the m_extendedTypes array if necessary.
if (m_extendedTypes.length == m_nextType) {
ExtendedType[] newArray = new ExtendedType[m_extendedTypes.length * 2];
System.arraycopy(m_extendedTypes, 0, newArray, 0,
m_extendedTypes.length);
m_extendedTypes = newArray;
}
m_extendedTypes[m_nextType] = newET;
// Create a new hash entry for the new ExtendedType and put it into
// the table.
HashEntry entry = new HashEntry(newET, m_nextType, hash, m_table[index]);
m_table[index] = entry;
return m_nextType++;
}
/**
* Increases the capacity of and internally reorganizes the hashtable,
* in order to accommodate and access its entries more efficiently.
* This method is called when the number of keys in the hashtable exceeds
* this hashtable's capacity and load factor.
*/
private void rehash()
{
int oldCapacity = m_capacity;
HashEntry[] oldTable = m_table;
int newCapacity = 2 * oldCapacity + 1;
m_capacity = newCapacity;
m_threshold = (int)(newCapacity * m_loadFactor);
m_table = new HashEntry[newCapacity];
for (int i = oldCapacity-1; i >=0 ; i--)
{
for (HashEntry old = oldTable[i]; old != null; )
{
HashEntry e = old;
old = old.next;
int newIndex = e.hash % newCapacity;
if (newIndex < 0)
newIndex = -newIndex;
e.next = m_table[newIndex];
m_table[newIndex] = e;
}
}
}
/**
* Given a type, return an expanded name ID.Any additional nodes that are
* created that have this expanded name will use this ID.
*
* @return the expanded-name id of the node.
*/
public int getExpandedTypeID(int type)
{
return type;
}
/**
* Given an expanded-name ID, return the local name part.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return String Local name of this node, or null if the node has no name.
*/
public String getLocalName(int ExpandedNameID)
{
return m_extendedTypes[ExpandedNameID].getLocalName();
}
/**
* Given an expanded-name ID, return the local name ID.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return The id of this local name.
*/
public final int getLocalNameID(int ExpandedNameID)
{
// ExtendedType etype = m_extendedTypes[ExpandedNameID];
if (m_extendedTypes[ExpandedNameID].getLocalName().equals(""))
return 0;
else
return ExpandedNameID;
}
/**
* Given an expanded-name ID, return the namespace URI part.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return String URI value of this node's namespace, or null if no
* namespace was resolved.
*/
public String getNamespace(int ExpandedNameID)
{
String namespace = m_extendedTypes[ExpandedNameID].getNamespace();
return (namespace.equals("") ? null : namespace);
}
/**
* Given an expanded-name ID, return the namespace URI ID.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return The id of this namespace.
*/
public final int getNamespaceID(int ExpandedNameID)
{
//ExtendedType etype = m_extendedTypes[ExpandedNameID];
if (m_extendedTypes[ExpandedNameID].getNamespace().equals(""))
return 0;
else
return ExpandedNameID;
}
/**
* Given an expanded-name ID, return the local name ID.
*
* @param ExpandedNameID an ID that represents an expanded-name.
* @return The id of this local name.
*/
public final short getType(int ExpandedNameID)
{
//ExtendedType etype = m_extendedTypes[ExpandedNameID];
return (short)m_extendedTypes[ExpandedNameID].getNodeType();
}
/**
* Return the size of the ExpandedNameTable
*
* @return The size of the ExpandedNameTable
*/
public int getSize()
{
return m_nextType;
}
/**
* Return the array of extended types
*
* @return The array of extended types
*/
public ExtendedType[] getExtendedTypes()
{
return m_extendedTypes;
}
/**
* Inner class which represents a hash table entry.
* The field next points to the next entry which is hashed into
* the same bucket in the case of "hash collision".
*/
private static final class HashEntry
{
ExtendedType key;
int value;
int hash;
HashEntry next;
protected HashEntry(ExtendedType key, int value, int hash, HashEntry next)
{
this.key = key;
this.value = value;
this.hash = hash;
this.next = next;
}
}
}

View File

@@ -0,0 +1,146 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
/**
* The class ExtendedType represents an extended type object used by
* ExpandedNameTable.
*/
public final class ExtendedType
{
private int nodetype;
private String namespace;
private String localName;
private int hash;
/**
* Create an ExtendedType object from node type, namespace and local name.
* The hash code is calculated from the node type, namespace and local name.
*
* @param nodetype Type of the node
* @param namespace Namespace of the node
* @param localName Local name of the node
*/
public ExtendedType (int nodetype, String namespace, String localName)
{
this.nodetype = nodetype;
this.namespace = namespace;
this.localName = localName;
this.hash = nodetype + namespace.hashCode() + localName.hashCode();
}
/**
* Create an ExtendedType object from node type, namespace, local name
* and a given hash code.
*
* @param nodetype Type of the node
* @param namespace Namespace of the node
* @param localName Local name of the node
* @param hash The given hash code
*/
public ExtendedType (int nodetype, String namespace, String localName, int hash)
{
this.nodetype = nodetype;
this.namespace = namespace;
this.localName = localName;
this.hash = hash;
}
/**
* Redefine this ExtendedType object to represent a different extended type.
* This is intended to be used ONLY on the hashET object. Using it elsewhere
* will mess up existing hashtable entries!
*/
protected void redefine(int nodetype, String namespace, String localName)
{
this.nodetype = nodetype;
this.namespace = namespace;
this.localName = localName;
this.hash = nodetype + namespace.hashCode() + localName.hashCode();
}
/**
* Redefine this ExtendedType object to represent a different extended type.
* This is intended to be used ONLY on the hashET object. Using it elsewhere
* will mess up existing hashtable entries!
*/
protected void redefine(int nodetype, String namespace, String localName, int hash)
{
this.nodetype = nodetype;
this.namespace = namespace;
this.localName = localName;
this.hash = hash;
}
/**
* Override the hashCode() method in the Object class
*/
public int hashCode()
{
return hash;
}
/**
* Test if this ExtendedType object is equal to the given ExtendedType.
*
* @param other The other ExtendedType object to test for equality
* @return true if the two ExtendedType objects are equal.
*/
public boolean equals(ExtendedType other)
{
try
{
return other.nodetype == this.nodetype &&
other.localName.equals(this.localName) &&
other.namespace.equals(this.namespace);
}
catch(NullPointerException e)
{
return false;
}
}
/**
* Return the node type
*/
public int getNodeType()
{
return nodetype;
}
/**
* Return the local name
*/
public String getLocalName()
{
return localName;
}
/**
* Return the namespace
*/
public String getNamespace()
{
return namespace;
}
}

View File

@@ -0,0 +1,89 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/** <p>IncrementalSAXSource is an API that delivers a small number of
* SAX events each time a request is made from a "controller"
* coroutine. See IncrementalSAXFilter and IncrementalSAXFilter_Xerces
* for examples.
*
* Note that interaction is via the deliverMoreNodes
* method, and therefore coroutine support is not exposed
* here.</p>
* */
public interface IncrementalSAXSource
{
// ------------------------------------------------------------------
// SAX Output API
// ------------------------------------------------------------------
/** Register a SAX-style content handler for us to output to
*/
public void setContentHandler(ContentHandler handler);
/** Register a SAX-style lexical handler for us to output to
*/
public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler);
/** Register a SAX-style DTD handler for us to output to
*/
public void setDTDHandler(org.xml.sax.DTDHandler handler);
// ------------------------------------------------------------------
// Command Input API
// ------------------------------------------------------------------
/** deliverMoreNodes() is a simple API which tells the thread in which the
* IncrementalSAXSource is running to deliver more events (true),
* or stop delivering events and close out its input (false).
*
* This is intended to be called from one of our partner coroutines,
* and serves to encapsulate the coroutine communication protocol.
*
* @param parsemore If true, tells the incremental SAX stream to deliver
* another chunk of events. If false, finishes out the stream.
*
* @return Boolean.TRUE if the IncrementalSAXSource believes more data
* may be available for further parsing. Boolean.FALSE if parsing
* ran to completion, or was ended by deliverMoreNodes(false).
* */
public Object deliverMoreNodes (boolean parsemore);
// ------------------------------------------------------------------
// Parse Thread Convenience API
// ------------------------------------------------------------------
/** Launch an XMLReader's parsing operation, feeding events to this
* IncrementalSAXSource. In some implementations, this may launch a
* thread which runs the previously supplied XMLReader's parse() operation.
* In others, it may do other forms of initialization.
*
* @throws SAXException is parse thread is already in progress
* or parsing can not be started.
* */
public void startParse(InputSource source) throws SAXException;
} // class IncrementalSAXSource

View File

@@ -0,0 +1,811 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import java.io.IOException;
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
import com.sun.org.apache.xml.internal.utils.ThreadControllerWrapper;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
/** <p>IncrementalSAXSource_Filter implements IncrementalSAXSource, using a
* standard SAX2 event source as its input and parcelling out those
* events gradually in reponse to deliverMoreNodes() requests. Output from the
* filter will be passed along to a SAX handler registered as our
* listener, but those callbacks will pass through a counting stage
* which periodically yields control back to the controller coroutine.
* </p>
*
* <p>%REVIEW%: This filter is not currenly intended to be reusable
* for parsing additional streams/documents. We may want to consider
* making it resettable at some point in the future. But it's a
* small object, so that'd be mostly a convenience issue; the cost
* of allocating each time is trivial compared to the cost of processing
* any nontrival stream.</p>
*
* <p>For a brief usage example, see the unit-test main() method.</p>
*
* <p>This is a simplification of the old CoroutineSAXParser, focusing
* specifically on filtering. The resulting controller protocol is _far_
* simpler and less error-prone; the only controller operation is deliverMoreNodes(),
* and the only requirement is that deliverMoreNodes(false) be called if you want to
* discard the rest of the stream and the previous deliverMoreNodes() didn't return
* false.
*
* This class is final and package private for security reasons. Please
* see CR 6537912 for further details.
*
* */
final class IncrementalSAXSource_Filter
implements IncrementalSAXSource, ContentHandler, DTDHandler, LexicalHandler, ErrorHandler, Runnable
{
boolean DEBUG=false; //Internal status report
//
// Data
//
private CoroutineManager fCoroutineManager = null;
private int fControllerCoroutineID = -1;
private int fSourceCoroutineID = -1;
private ContentHandler clientContentHandler=null; // %REVIEW% support multiple?
private LexicalHandler clientLexicalHandler=null; // %REVIEW% support multiple?
private DTDHandler clientDTDHandler=null; // %REVIEW% support multiple?
private ErrorHandler clientErrorHandler=null; // %REVIEW% support multiple?
private int eventcounter;
private int frequency=5;
// Flag indicating that no more events should be delivered -- either
// because input stream ran to completion (endDocument), or because
// the user requested an early stop via deliverMoreNodes(false).
private boolean fNoMoreEvents=false;
// Support for startParse()
private XMLReader fXMLReader=null;
private InputSource fXMLReaderInputSource=null;
//
// Constructors
//
public IncrementalSAXSource_Filter() {
this.init( new CoroutineManager(), -1, -1);
}
/** Create a IncrementalSAXSource_Filter which is not yet bound to a specific
* SAX event source.
* */
public IncrementalSAXSource_Filter(CoroutineManager co, int controllerCoroutineID)
{
this.init( co, controllerCoroutineID, -1 );
}
//
// Factories
//
static public IncrementalSAXSource createIncrementalSAXSource(CoroutineManager co, int controllerCoroutineID) {
return new IncrementalSAXSource_Filter(co, controllerCoroutineID);
}
//
// Public methods
//
public void init( CoroutineManager co, int controllerCoroutineID,
int sourceCoroutineID)
{
if(co==null)
co = new CoroutineManager();
fCoroutineManager = co;
fControllerCoroutineID = co.co_joinCoroutineSet(controllerCoroutineID);
fSourceCoroutineID = co.co_joinCoroutineSet(sourceCoroutineID);
if (fControllerCoroutineID == -1 || fSourceCoroutineID == -1)
throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COJOINROUTINESET_FAILED, null)); //"co_joinCoroutineSet() failed");
fNoMoreEvents=false;
eventcounter=frequency;
}
/** Bind our input streams to an XMLReader.
*
* Just a convenience routine; obviously you can explicitly register
* this as a listener with the same effect.
* */
public void setXMLReader(XMLReader eventsource)
{
fXMLReader=eventsource;
eventsource.setContentHandler(this);
eventsource.setDTDHandler(this);
eventsource.setErrorHandler(this); // to report fatal errors in filtering mode
// Not supported by all SAX2 filters:
try
{
eventsource.
setProperty("http://xml.org/sax/properties/lexical-handler",
this);
}
catch(SAXNotRecognizedException e)
{
// Nothing we can do about it
}
catch(SAXNotSupportedException e)
{
// Nothing we can do about it
}
// Should we also bind as other varieties of handler?
// (DTDHandler and so on)
}
// Register a content handler for us to output to
public void setContentHandler(ContentHandler handler)
{
clientContentHandler=handler;
}
// Register a DTD handler for us to output to
public void setDTDHandler(DTDHandler handler)
{
clientDTDHandler=handler;
}
// Register a lexical handler for us to output to
// Not all filters support this...
// ??? Should we register directly on the filter?
// NOTE NAME -- subclassing issue in the Xerces version
public void setLexicalHandler(LexicalHandler handler)
{
clientLexicalHandler=handler;
}
// Register an error handler for us to output to
// NOTE NAME -- subclassing issue in the Xerces version
public void setErrHandler(ErrorHandler handler)
{
clientErrorHandler=handler;
}
// Set the number of events between resumes of our coroutine
// Immediately resets number of events before _next_ resume as well.
public void setReturnFrequency(int events)
{
if(events<1) events=1;
frequency=eventcounter=events;
}
//
// ContentHandler methods
// These pass the data to our client ContentHandler...
// but they also count the number of events passing through,
// and resume our coroutine each time that counter hits zero and
// is reset.
//
// Note that for everything except endDocument and fatalError, we do the count-and-yield
// BEFORE passing the call along. I'm hoping that this will encourage JIT
// compilers to realize that these are tail-calls, reducing the expense of
// the additional layer of data flow.
//
// %REVIEW% Glenn suggests that pausing after endElement, endDocument,
// and characters may be sufficient. I actually may not want to
// stop after characters, since in our application these wind up being
// concatenated before they're processed... but that risks huge blocks of
// text causing greater than usual readahead. (Unlikely? Consider the
// possibility of a large base-64 block in a SOAP stream.)
//
public void characters(char[] ch, int start, int length)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.characters(ch,start,length);
}
public void endDocument()
throws org.xml.sax.SAXException
{
// EXCEPTION: In this case we need to run the event BEFORE we yield.
if(clientContentHandler!=null)
clientContentHandler.endDocument();
eventcounter=0;
co_yield(false);
}
public void endElement(java.lang.String namespaceURI, java.lang.String localName,
java.lang.String qName)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.endElement(namespaceURI,localName,qName);
}
public void endPrefixMapping(java.lang.String prefix)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.endPrefixMapping(prefix);
}
public void ignorableWhitespace(char[] ch, int start, int length)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.ignorableWhitespace(ch,start,length);
}
public void processingInstruction(java.lang.String target, java.lang.String data)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.processingInstruction(target,data);
}
public void setDocumentLocator(Locator locator)
{
if(--eventcounter<=0)
{
// This can cause a hang. -sb
// co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.setDocumentLocator(locator);
}
public void skippedEntity(java.lang.String name)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.skippedEntity(name);
}
public void startDocument()
throws org.xml.sax.SAXException
{
co_entry_pause();
// Otherwise, begin normal event delivery
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.startDocument();
}
public void startElement(java.lang.String namespaceURI, java.lang.String localName,
java.lang.String qName, Attributes atts)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.startElement(namespaceURI, localName, qName, atts);
}
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
throws org.xml.sax.SAXException
{
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
if(clientContentHandler!=null)
clientContentHandler.startPrefixMapping(prefix,uri);
}
//
// LexicalHandler support. Not all SAX2 filters support these events
// but we may want to pass them through when they exist...
//
// %REVIEW% These do NOT currently affect the eventcounter; I'm asserting
// that they're rare enough that it makes little or no sense to
// pause after them. As such, it may make more sense for folks who
// actually want to use them to register directly with the filter.
// But I want 'em here for now, to remind us to recheck this assertion!
//
public void comment(char[] ch, int start, int length)
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler.comment(ch,start,length);
}
public void endCDATA()
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler.endCDATA();
}
public void endDTD()
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler.endDTD();
}
public void endEntity(java.lang.String name)
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler.endEntity(name);
}
public void startCDATA()
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler.startCDATA();
}
public void startDTD(java.lang.String name, java.lang.String publicId,
java.lang.String systemId)
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler. startDTD(name, publicId, systemId);
}
public void startEntity(java.lang.String name)
throws org.xml.sax.SAXException
{
if(null!=clientLexicalHandler)
clientLexicalHandler.startEntity(name);
}
//
// DTDHandler support.
public void notationDecl(String a, String b, String c) throws SAXException
{
if(null!=clientDTDHandler)
clientDTDHandler.notationDecl(a,b,c);
}
public void unparsedEntityDecl(String a, String b, String c, String d) throws SAXException
{
if(null!=clientDTDHandler)
clientDTDHandler.unparsedEntityDecl(a,b,c,d);
}
//
// ErrorHandler support.
//
// PROBLEM: Xerces is apparently _not_ calling the ErrorHandler for
// exceptions thrown by the ContentHandler, which prevents us from
// handling this properly when running in filtering mode with Xerces
// as our event source. It's unclear whether this is a Xerces bug
// or a SAX design flaw.
//
// %REVIEW% Current solution: In filtering mode, it is REQUIRED that
// event source make sure this method is invoked if the event stream
// abends before endDocument is delivered. If that means explicitly calling
// us in the exception handling code because it won't be delivered as part
// of the normal SAX ErrorHandler stream, that's fine; Not Our Problem.
//
public void error(SAXParseException exception) throws SAXException
{
if(null!=clientErrorHandler)
clientErrorHandler.error(exception);
}
public void fatalError(SAXParseException exception) throws SAXException
{
// EXCEPTION: In this case we need to run the event BEFORE we yield --
// just as with endDocument, this terminates the event stream.
if(null!=clientErrorHandler)
clientErrorHandler.error(exception);
eventcounter=0;
co_yield(false);
}
public void warning(SAXParseException exception) throws SAXException
{
if(null!=clientErrorHandler)
clientErrorHandler.error(exception);
}
//
// coroutine support
//
public int getSourceCoroutineID() {
return fSourceCoroutineID;
}
public int getControllerCoroutineID() {
return fControllerCoroutineID;
}
/** @return the CoroutineManager this CoroutineFilter object is bound to.
* If you're using the do...() methods, applications should only
* need to talk to the CoroutineManager once, to obtain the
* application's Coroutine ID.
* */
public CoroutineManager getCoroutineManager()
{
return fCoroutineManager;
}
/** <p>In the SAX delegation code, I've inlined the count-down in
* the hope of encouraging compilers to deliver better
* performance. However, if we subclass (eg to directly connect the
* output to a DTM builder), that would require calling super in
* order to run that logic... which seems inelegant. Hence this
* routine for the convenience of subclasses: every [frequency]
* invocations, issue a co_yield.</p>
*
* @param moreExepected Should always be true unless this is being called
* at the end of endDocument() handling.
* */
protected void count_and_yield(boolean moreExpected) throws SAXException
{
if(!moreExpected) eventcounter=0;
if(--eventcounter<=0)
{
co_yield(true);
eventcounter=frequency;
}
}
/**
* co_entry_pause is called in startDocument() before anything else
* happens. It causes the filter to wait for a "go ahead" request
* from the controller before delivering any events. Note that
* the very first thing the controller tells us may be "I don't
* need events after all"!
*/
private void co_entry_pause() throws SAXException
{
if(fCoroutineManager==null)
{
// Nobody called init()? Do it now...
init(null,-1,-1);
}
try
{
Object arg=fCoroutineManager.co_entry_pause(fSourceCoroutineID);
if(arg==Boolean.FALSE)
co_yield(false);
}
catch(NoSuchMethodException e)
{
// Coroutine system says we haven't registered. That's an
// application coding error, and is unrecoverable.
if(DEBUG) e.printStackTrace();
throw new SAXException(e);
}
}
/**
* Co_Yield handles coroutine interactions while a parse is in progress.
*
* When moreRemains==true, we are pausing after delivering events, to
* ask if more are needed. We will resume the controller thread with
* co_resume(Boolean.TRUE, ...)
* When control is passed back it may indicate
* Boolean.TRUE indication to continue delivering events
* Boolean.FALSE indication to discontinue events and shut down.
*
* When moreRemains==false, we shut down immediately without asking the
* controller's permission. Normally this means end of document has been
* reached.
*
* Shutting down a IncrementalSAXSource_Filter requires terminating the incoming
* SAX event stream. If we are in control of that stream (if it came
* from an XMLReader passed to our startReader() method), we can do so
* very quickly by throwing a reserved exception to it. If the stream is
* coming from another source, we can't do that because its caller may
* not be prepared for this "normal abnormal exit", and instead we put
* ourselves in a "spin" mode where events are discarded.
*/
private void co_yield(boolean moreRemains) throws SAXException
{
// Horrendous kluge to run filter to completion. See below.
if(fNoMoreEvents)
return;
try // Coroutine manager might throw no-such.
{
Object arg=Boolean.FALSE;
if(moreRemains)
{
// Yield control, resume parsing when done
arg = fCoroutineManager.co_resume(Boolean.TRUE, fSourceCoroutineID,
fControllerCoroutineID);
}
// If we're at end of document or were told to stop early
if(arg==Boolean.FALSE)
{
fNoMoreEvents=true;
if(fXMLReader!=null) // Running under startParseThread()
throw new StopException(); // We'll co_exit from there.
// Yield control. We do NOT expect anyone to ever ask us again.
fCoroutineManager.co_exit_to(Boolean.FALSE, fSourceCoroutineID,
fControllerCoroutineID);
}
}
catch(NoSuchMethodException e)
{
// Shouldn't happen unless we've miscoded our coroutine logic
// "Shut down the garbage smashers on the detention level!"
fNoMoreEvents=true;
fCoroutineManager.co_exit(fSourceCoroutineID);
throw new SAXException(e);
}
}
//
// Convenience: Run an XMLReader in a thread
//
/** Launch a thread that will run an XMLReader's parse() operation within
* a thread, feeding events to this IncrementalSAXSource_Filter. Mostly a convenience
* routine, but has the advantage that -- since we invoked parse() --
* we can halt parsing quickly via a StopException rather than waiting
* for the SAX stream to end by itself.
*
* @throws SAXException is parse thread is already in progress
* or parsing can not be started.
* */
public void startParse(InputSource source) throws SAXException
{
if(fNoMoreEvents)
throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_INCRSAXSRCFILTER_NOT_RESTARTABLE, null)); //"IncrmentalSAXSource_Filter not currently restartable.");
if(fXMLReader==null)
throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_XMLRDR_NOT_BEFORE_STARTPARSE, null)); //"XMLReader not before startParse request");
fXMLReaderInputSource=source;
// Xalan thread pooling...
// com.sun.org.apache.xalan.internal.transformer.TransformerImpl.runTransformThread(this);
ThreadControllerWrapper.runThread(this, -1);
}
/* Thread logic to support startParseThread()
*/
public void run()
{
// Guard against direct invocation of start().
if(fXMLReader==null) return;
if(DEBUG)System.out.println("IncrementalSAXSource_Filter parse thread launched");
// Initially assume we'll run successfully.
Object arg=Boolean.FALSE;
// For the duration of this operation, all coroutine handshaking
// will occur in the co_yield method. That's the nice thing about
// coroutines; they give us a way to hand off control from the
// middle of a synchronous method.
try
{
fXMLReader.parse(fXMLReaderInputSource);
}
catch(IOException ex)
{
arg=ex;
}
catch(StopException ex)
{
// Expected and harmless
if(DEBUG)System.out.println("Active IncrementalSAXSource_Filter normal stop exception");
}
catch (SAXException ex)
{
Exception inner=ex.getException();
if(inner instanceof StopException){
// Expected and harmless
if(DEBUG)System.out.println("Active IncrementalSAXSource_Filter normal stop exception");
}
else
{
// Unexpected malfunction
if(DEBUG)
{
System.out.println("Active IncrementalSAXSource_Filter UNEXPECTED SAX exception: "+inner);
inner.printStackTrace();
}
arg=ex;
}
} // end parse
// Mark as no longer running in thread.
fXMLReader=null;
try
{
// Mark as done and yield control to the controller coroutine
fNoMoreEvents=true;
fCoroutineManager.co_exit_to(arg, fSourceCoroutineID,
fControllerCoroutineID);
}
catch(java.lang.NoSuchMethodException e)
{
// Shouldn't happen unless we've miscoded our coroutine logic
// "CPO, shut down the garbage smashers on the detention level!"
e.printStackTrace(System.err);
fCoroutineManager.co_exit(fSourceCoroutineID);
}
}
/** Used to quickly terminate parse when running under a
startParse() thread. Only its type is important. */
class StopException extends RuntimeException
{
static final long serialVersionUID = -1129245796185754956L;
}
/** deliverMoreNodes() is a simple API which tells the coroutine
* parser that we need more nodes. This is intended to be called
* from one of our partner routines, and serves to encapsulate the
* details of how incremental parsing has been achieved.
*
* @param parsemore If true, tells the incremental filter to generate
* another chunk of output. If false, tells the filter that we're
* satisfied and it can terminate parsing of this document.
*
* @return Boolean.TRUE if there may be more events available by invoking
* deliverMoreNodes() again. Boolean.FALSE if parsing has run to completion (or been
* terminated by deliverMoreNodes(false). Or an exception object if something
* malfunctioned. %REVIEW% We _could_ actually throw the exception, but
* that would require runinng deliverMoreNodes() in a try/catch... and for many
* applications, exception will be simply be treated as "not TRUE" in
* any case.
* */
public Object deliverMoreNodes(boolean parsemore)
{
// If parsing is already done, we can immediately say so
if(fNoMoreEvents)
return Boolean.FALSE;
try
{
Object result =
fCoroutineManager.co_resume(parsemore?Boolean.TRUE:Boolean.FALSE,
fControllerCoroutineID, fSourceCoroutineID);
if(result==Boolean.FALSE)
fCoroutineManager.co_exit(fControllerCoroutineID);
return result;
}
// SHOULD NEVER OCCUR, since the coroutine number and coroutine manager
// are those previously established for this IncrementalSAXSource_Filter...
// So I'm just going to return it as a parsing exception, for now.
catch(NoSuchMethodException e)
{
return e;
}
}
//================================================================
/** Simple unit test. Attempt coroutine parsing of document indicated
* by first argument (as a URI), report progress.
*/
/*
public static void _main(String args[])
{
System.out.println("Starting...");
org.xml.sax.XMLReader theSAXParser=
new com.sun.org.apache.xerces.internal.parsers.SAXParser();
for(int arg=0;arg<args.length;++arg)
{
// The filter is not currently designed to be restartable
// after a parse has ended. Generate a new one each time.
IncrementalSAXSource_Filter filter=
new IncrementalSAXSource_Filter();
// Use a serializer as our sample output
com.sun.org.apache.xml.internal.serialize.XMLSerializer trace;
trace=new com.sun.org.apache.xml.internal.serialize.XMLSerializer(System.out,null);
filter.setContentHandler(trace);
filter.setLexicalHandler(trace);
try
{
InputSource source = new InputSource(args[arg]);
Object result=null;
boolean more=true;
// init not issued; we _should_ automagically Do The Right Thing
// Bind parser, kick off parsing in a thread
filter.setXMLReader(theSAXParser);
filter.startParse(source);
for(result = filter.deliverMoreNodes(more);
(result instanceof Boolean && ((Boolean)result)==Boolean.TRUE);
result = filter.deliverMoreNodes(more))
{
System.out.println("\nSome parsing successful, trying more.\n");
// Special test: Terminate parsing early.
if(arg+1<args.length && "!".equals(args[arg+1]))
{
++arg;
more=false;
}
}
if (result instanceof Boolean && ((Boolean)result)==Boolean.FALSE)
{
System.out.println("\nFilter ended (EOF or on request).\n");
}
else if (result == null) {
System.out.println("\nUNEXPECTED: Filter says shut down prematurely.\n");
}
else if (result instanceof Exception) {
System.out.println("\nFilter threw exception:");
((Exception)result).printStackTrace();
}
}
catch(SAXException e)
{
e.printStackTrace();
}
} // end for
}
*/
} // class IncrementalSAXSource_Filter

View File

@@ -0,0 +1,455 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import com.sun.org.apache.xerces.internal.parsers.SAXParser;
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
/** <p>IncrementalSAXSource_Xerces takes advantage of the fact that Xerces1
* incremental mode is already a coroutine of sorts, and just wraps our
* IncrementalSAXSource API around it.</p>
*
* <p>Usage example: See main().</p>
*
* <p>Status: Passes simple main() unit-test. NEEDS JAVADOC.</p>
* */
public class IncrementalSAXSource_Xerces
implements IncrementalSAXSource
{
//
// Reflection. To allow this to compile with both Xerces1 and Xerces2, which
// require very different methods and objects, we need to avoid static
// references to those APIs. So until Xerces2 is pervasive and we're willing
// to make it a prerequisite, we will rely upon relection.
//
Method fParseSomeSetup=null; // Xerces1 method
Method fParseSome=null; // Xerces1 method
Object fPullParserConfig=null; // Xerces2 pull control object
Method fConfigSetInput=null; // Xerces2 method
Method fConfigParse=null; // Xerces2 method
Method fSetInputSource=null; // Xerces2 pull control method
Constructor fConfigInputSourceCtor=null; // Xerces2 initialization method
Method fConfigSetByteStream=null; // Xerces2 initialization method
Method fConfigSetCharStream=null; // Xerces2 initialization method
Method fConfigSetEncoding=null; // Xerces2 initialization method
Method fReset=null; // Both Xerces1 and Xerces2, but diff. signatures
//
// Data
//
SAXParser fIncrementalParser;
private boolean fParseInProgress=false;
//
// Constructors
//
/** Create a IncrementalSAXSource_Xerces, and create a SAXParser
* to go with it. Xerces2 incremental parsing is only supported if
* this constructor is used, due to limitations in the Xerces2 API (as of
* Beta 3). If you don't like that restriction, tell the Xerces folks that
* there should be a simpler way to request incremental SAX parsing.
* */
public IncrementalSAXSource_Xerces()
throws NoSuchMethodException
{
try
{
// Xerces-2 incremental parsing support (as of Beta 3)
// ContentHandlers still get set on fIncrementalParser (to get
// conversion from XNI events to SAX events), but
// _control_ for incremental parsing must be exercised via the config.
//
// At this time there's no way to read the existing config, only
// to assert a new one... and only when creating a brand-new parser.
//
// Reflection is used to allow us to continue to compile against
// Xerces1. If/when we can abandon the older versions of the parser,
// this will simplify significantly.
// If we can't get the magic constructor, no need to look further.
Class xniConfigClass=ObjectFactory.findProviderClass(
"com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration",
true);
Class[] args1={xniConfigClass};
Constructor ctor=SAXParser.class.getConstructor(args1);
// Build the parser configuration object. StandardParserConfiguration
// happens to implement XMLPullParserConfiguration, which is the API
// we're going to want to use.
Class xniStdConfigClass=ObjectFactory.findProviderClass(
"com.sun.org.apache.xerces.internal.parsers.StandardParserConfiguration",
true);
fPullParserConfig=xniStdConfigClass.newInstance();
Object[] args2={fPullParserConfig};
fIncrementalParser = (SAXParser)ctor.newInstance(args2);
// Preload all the needed the configuration methods... I want to know they're
// all here before we commit to trying to use them, just in case the
// API changes again.
Class fXniInputSourceClass=ObjectFactory.findProviderClass(
"com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource",
true);
Class[] args3={fXniInputSourceClass};
fConfigSetInput=xniStdConfigClass.getMethod("setInputSource",args3);
Class[] args4={String.class,String.class,String.class};
fConfigInputSourceCtor=fXniInputSourceClass.getConstructor(args4);
Class[] args5={java.io.InputStream.class};
fConfigSetByteStream=fXniInputSourceClass.getMethod("setByteStream",args5);
Class[] args6={java.io.Reader.class};
fConfigSetCharStream=fXniInputSourceClass.getMethod("setCharacterStream",args6);
Class[] args7={String.class};
fConfigSetEncoding=fXniInputSourceClass.getMethod("setEncoding",args7);
Class[] argsb={Boolean.TYPE};
fConfigParse=xniStdConfigClass.getMethod("parse",argsb);
Class[] noargs=new Class[0];
fReset=fIncrementalParser.getClass().getMethod("reset",noargs);
}
catch(Exception e)
{
// Fallback if this fails (implemented in createIncrementalSAXSource) is
// to attempt Xerces-1 incremental setup. Can't do tail-call in
// constructor, so create new, copy Xerces-1 initialization,
// then throw it away... Ugh.
IncrementalSAXSource_Xerces dummy=new IncrementalSAXSource_Xerces(new SAXParser());
this.fParseSomeSetup=dummy.fParseSomeSetup;
this.fParseSome=dummy.fParseSome;
this.fIncrementalParser=dummy.fIncrementalParser;
}
}
/** Create a IncrementalSAXSource_Xerces wrapped around
* an existing SAXParser. Currently this works only for recent
* releases of Xerces-1. Xerces-2 incremental is currently possible
* only if we are allowed to create the parser instance, due to
* limitations in the API exposed by Xerces-2 Beta 3; see the
* no-args constructor for that code.
*
* @exception if the SAXParser class doesn't support the Xerces
* incremental parse operations. In that case, caller should
* fall back upon the IncrementalSAXSource_Filter approach.
* */
public IncrementalSAXSource_Xerces(SAXParser parser)
throws NoSuchMethodException
{
// Reflection is used to allow us to compile against
// Xerces2. If/when we can abandon the older versions of the parser,
// this constructor will simply have to fail until/unless the
// Xerces2 incremental support is made available on previously
// constructed SAXParser instances.
fIncrementalParser=parser;
Class me=parser.getClass();
Class[] parms={InputSource.class};
fParseSomeSetup=me.getMethod("parseSomeSetup",parms);
parms=new Class[0];
fParseSome=me.getMethod("parseSome",parms);
// Fallback if this fails (implemented in createIncrementalSAXSource) is
// to use IncrementalSAXSource_Filter rather than Xerces-specific code.
}
//
// Factories
//
static public IncrementalSAXSource createIncrementalSAXSource()
{
try
{
return new IncrementalSAXSource_Xerces();
}
catch(NoSuchMethodException e)
{
// Xerces version mismatch; neither Xerces1 nor Xerces2 succeeded.
// Fall back on filtering solution.
IncrementalSAXSource_Filter iss=new IncrementalSAXSource_Filter();
iss.setXMLReader(new SAXParser());
return iss;
}
}
static public IncrementalSAXSource
createIncrementalSAXSource(SAXParser parser) {
try
{
return new IncrementalSAXSource_Xerces(parser);
}
catch(NoSuchMethodException e)
{
// Xerces version mismatch; neither Xerces1 nor Xerces2 succeeded.
// Fall back on filtering solution.
IncrementalSAXSource_Filter iss=new IncrementalSAXSource_Filter();
iss.setXMLReader(parser);
return iss;
}
}
//
// Public methods
//
// Register handler directly with the incremental parser
public void setContentHandler(org.xml.sax.ContentHandler handler)
{
// Typecast required in Xerces2; SAXParser doesn't inheret XMLReader
// %OPT% Cast at asignment?
((XMLReader)fIncrementalParser).setContentHandler(handler);
}
// Register handler directly with the incremental parser
public void setLexicalHandler(org.xml.sax.ext.LexicalHandler handler)
{
// Not supported by all SAX2 parsers but should work in Xerces:
try
{
// Typecast required in Xerces2; SAXParser doesn't inheret XMLReader
// %OPT% Cast at asignment?
((XMLReader)fIncrementalParser).setProperty("http://xml.org/sax/properties/lexical-handler",
handler);
}
catch(org.xml.sax.SAXNotRecognizedException e)
{
// Nothing we can do about it
}
catch(org.xml.sax.SAXNotSupportedException e)
{
// Nothing we can do about it
}
}
// Register handler directly with the incremental parser
public void setDTDHandler(org.xml.sax.DTDHandler handler)
{
// Typecast required in Xerces2; SAXParser doesn't inheret XMLReader
// %OPT% Cast at asignment?
((XMLReader)fIncrementalParser).setDTDHandler(handler);
}
//================================================================
/** startParse() is a simple API which tells the IncrementalSAXSource
* to begin reading a document.
*
* @throws SAXException is parse thread is already in progress
* or parsing can not be started.
* */
public void startParse(InputSource source) throws SAXException
{
if (fIncrementalParser==null)
throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_STARTPARSE_NEEDS_SAXPARSER, null)); //"startParse needs a non-null SAXParser.");
if (fParseInProgress)
throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_STARTPARSE_WHILE_PARSING, null)); //"startParse may not be called while parsing.");
boolean ok=false;
try
{
ok = parseSomeSetup(source);
}
catch(Exception ex)
{
throw new SAXException(ex);
}
if(!ok)
throw new SAXException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COULD_NOT_INIT_PARSER, null)); //"could not initialize parser with");
}
/** deliverMoreNodes() is a simple API which tells the coroutine
* parser that we need more nodes. This is intended to be called
* from one of our partner routines, and serves to encapsulate the
* details of how incremental parsing has been achieved.
*
* @param parsemore If true, tells the incremental parser to generate
* another chunk of output. If false, tells the parser that we're
* satisfied and it can terminate parsing of this document.
* @return Boolean.TRUE if the CoroutineParser believes more data may be available
* for further parsing. Boolean.FALSE if parsing ran to completion.
* Exception if the parser objected for some reason.
* */
public Object deliverMoreNodes (boolean parsemore)
{
if(!parsemore)
{
fParseInProgress=false;
return Boolean.FALSE;
}
Object arg;
try {
boolean keepgoing = parseSome();
arg = keepgoing ? Boolean.TRUE : Boolean.FALSE;
} catch (SAXException ex) {
arg = ex;
} catch (IOException ex) {
arg = ex;
} catch (Exception ex) {
arg = new SAXException(ex);
}
return arg;
}
// Private methods -- conveniences to hide the reflection details
private boolean parseSomeSetup(InputSource source)
throws SAXException, IOException, IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.InstantiationException
{
if(fConfigSetInput!=null)
{
// Obtain input from SAX inputSource object, construct XNI version of
// that object. Logic adapted from Xerces2.
Object[] parms1={source.getPublicId(),source.getSystemId(),null};
Object xmlsource=fConfigInputSourceCtor.newInstance(parms1);
Object[] parmsa={source.getByteStream()};
fConfigSetByteStream.invoke(xmlsource,parmsa);
parmsa[0]=source.getCharacterStream();
fConfigSetCharStream.invoke(xmlsource,parmsa);
parmsa[0]=source.getEncoding();
fConfigSetEncoding.invoke(xmlsource,parmsa);
// Bugzilla5272 patch suggested by Sandy Gao.
// Has to be reflection to run with Xerces2
// after compilation against Xerces1. or vice
// versa, due to return type mismatches.
Object[] noparms=new Object[0];
fReset.invoke(fIncrementalParser,noparms);
parmsa[0]=xmlsource;
fConfigSetInput.invoke(fPullParserConfig,parmsa);
// %REVIEW% Do first pull. Should we instead just return true?
return parseSome();
}
else
{
Object[] parm={source};
Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm);
return ((Boolean)ret).booleanValue();
}
}
// Would null work???
private static final Object[] noparms=new Object[0];
private static final Object[] parmsfalse={Boolean.FALSE};
private boolean parseSome()
throws SAXException, IOException, IllegalAccessException,
java.lang.reflect.InvocationTargetException
{
// Take next parsing step, return false iff parsing complete:
if(fConfigSetInput!=null)
{
Object ret=(Boolean)(fConfigParse.invoke(fPullParserConfig,parmsfalse));
return ((Boolean)ret).booleanValue();
}
else
{
Object ret=fParseSome.invoke(fIncrementalParser,noparms);
return ((Boolean)ret).booleanValue();
}
}
//================================================================
/** Simple unit test. Attempt coroutine parsing of document indicated
* by first argument (as a URI), report progress.
*/
public static void _main(String args[])
{
System.out.println("Starting...");
CoroutineManager co = new CoroutineManager();
int appCoroutineID = co.co_joinCoroutineSet(-1);
if (appCoroutineID == -1)
{
System.out.println("ERROR: Couldn't allocate coroutine number.\n");
return;
}
IncrementalSAXSource parser=
createIncrementalSAXSource();
// Use a serializer as our sample output
com.sun.org.apache.xml.internal.serialize.XMLSerializer trace;
trace=new com.sun.org.apache.xml.internal.serialize.XMLSerializer(System.out,null);
parser.setContentHandler(trace);
parser.setLexicalHandler(trace);
// Tell coroutine to begin parsing, run while parsing is in progress
for(int arg=0;arg<args.length;++arg)
{
try
{
InputSource source = new InputSource(args[arg]);
Object result=null;
boolean more=true;
parser.startParse(source);
for(result = parser.deliverMoreNodes(more);
result==Boolean.TRUE;
result = parser.deliverMoreNodes(more))
{
System.out.println("\nSome parsing successful, trying more.\n");
// Special test: Terminate parsing early.
if(arg+1<args.length && "!".equals(args[arg+1]))
{
++arg;
more=false;
}
}
if (result instanceof Boolean && ((Boolean)result)==Boolean.FALSE)
{
System.out.println("\nParser ended (EOF or on request).\n");
}
else if (result == null) {
System.out.println("\nUNEXPECTED: Parser says shut down prematurely.\n");
}
else if (result instanceof Exception) {
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException((Exception)result);
// System.out.println("\nParser threw exception:");
// ((Exception)result).printStackTrace();
}
}
catch(SAXException e)
{
e.printStackTrace();
}
}
}
} // class IncrementalSAXSource_Xerces

View File

@@ -0,0 +1,110 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref;
import javax.xml.transform.SourceLocator;
/**
* <code>NodeLocator</code> maintains information on an XML source
* node.
*
* @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
* @since May 23, 2001
*/
public class NodeLocator implements SourceLocator
{
protected String m_publicId;
protected String m_systemId;
protected int m_lineNumber;
protected int m_columnNumber;
/**
* Creates a new <code>NodeLocator</code> instance.
*
* @param publicId a <code>String</code> value
* @param systemId a <code>String</code> value
* @param lineNumber an <code>int</code> value
* @param columnNumber an <code>int</code> value
*/
public NodeLocator(String publicId, String systemId,
int lineNumber, int columnNumber)
{
this.m_publicId = publicId;
this.m_systemId = systemId;
this.m_lineNumber = lineNumber;
this.m_columnNumber = columnNumber;
}
/**
* <code>getPublicId</code> returns the public ID of the node.
*
* @return a <code>String</code> value
*/
public String getPublicId()
{
return m_publicId;
}
/**
* <code>getSystemId</code> returns the system ID of the node.
*
* @return a <code>String</code> value
*/
public String getSystemId()
{
return m_systemId;
}
/**
* <code>getLineNumber</code> returns the line number of the node.
*
* @return an <code>int</code> value
*/
public int getLineNumber()
{
return m_lineNumber;
}
/**
* <code>getColumnNumber</code> returns the column number of the
* node.
*
* @return an <code>int</code> value
*/
public int getColumnNumber()
{
return m_columnNumber;
}
/**
* <code>toString</code> returns a string representation of this
* NodeLocator instance.
*
* @return a <code>String</code> value
*/
public String toString()
{
return "file '" + m_systemId
+ "', line #" + m_lineNumber
+ ", column #" + m_columnNumber;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,678 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref.dom2dtm;
import com.sun.org.apache.xml.internal.dtm.DTMException;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
import org.w3c.dom.UserDataHandler;
import org.w3c.dom.DOMException;
/** This is a kluge to let us shove a declaration for xml: into the
* DOM2DTM model. Basically, it creates a proxy node in DOM space to
* carry the additional information. This is _NOT_ a full DOM
* implementation, and shouldn't be one since it sits alongside the
* DOM rather than becoming part of the DOM model.
*
* (This used to be an internal class within DOM2DTM. Moved out because
* I need to perform an instanceof operation on it to support a temporary
* workaround in DTMManagerDefault.)
*
* %REVIEW% What if the DOM2DTM was built around a DocumentFragment and
* there isn't a single root element? I think this fails that case...
*
* %REVIEW% An alternative solution would be to create the node _only_
* in DTM space, but given how DOM2DTM is currently written I think
* this is simplest.
* */
public class DOM2DTMdefaultNamespaceDeclarationNode implements Attr,TypeInfo
{
final String NOT_SUPPORTED_ERR="Unsupported operation on pseudonode";
Element pseudoparent;
String prefix,uri,nodename;
int handle;
DOM2DTMdefaultNamespaceDeclarationNode(Element pseudoparent,String prefix,String uri,int handle)
{
this.pseudoparent=pseudoparent;
this.prefix=prefix;
this.uri=uri;
this.handle=handle;
this.nodename="xmlns:"+prefix;
}
public String getNodeName() {return nodename;}
public String getName() {return nodename;}
public String getNamespaceURI() {return "http://www.w3.org/2000/xmlns/";}
public String getPrefix() {return prefix;}
public String getLocalName() {return prefix;}
public String getNodeValue() {return uri;}
public String getValue() {return uri;}
public Element getOwnerElement() {return pseudoparent;}
public boolean isSupported(String feature, String version) {return false;}
public boolean hasChildNodes() {return false;}
public boolean hasAttributes() {return false;}
public Node getParentNode() {return null;}
public Node getFirstChild() {return null;}
public Node getLastChild() {return null;}
public Node getPreviousSibling() {return null;}
public Node getNextSibling() {return null;}
public boolean getSpecified() {return false;}
public void normalize() {return;}
public NodeList getChildNodes() {return null;}
public NamedNodeMap getAttributes() {return null;}
public short getNodeType() {return Node.ATTRIBUTE_NODE;}
public void setNodeValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
public void setValue(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
public void setPrefix(String value) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node insertBefore(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node replaceChild(Node a, Node b) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node appendChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Node removeChild(Node a) {throw new DTMException(NOT_SUPPORTED_ERR);}
public Document getOwnerDocument() {return pseudoparent.getOwnerDocument();}
public Node cloneNode(boolean deep) {throw new DTMException(NOT_SUPPORTED_ERR);}
/** Non-DOM method, part of the temporary kluge
* %REVIEW% This would be a pruning problem, but since it will always be
* added to the root element and we prune on elements, we shouldn't have
* to worry.
*/
public int getHandleOfNode()
{
return handle;
}
//RAMESH: PENDING=> Add proper implementation for the below DOM L3 additions
/**
* @see org.w3c.dom.TypeInfo#getTypeName()
*/
public String getTypeName() {return null; }
/**
* @see org.w3c.dom.TypeInfo#getTypeNamespace()
*/
public String getTypeNamespace() { return null;}
/**
* @see or.gw3c.dom.TypeInfo#isDerivedFrom(String,String,int)
*/
public boolean isDerivedFrom( String ns, String localName, int derivationMethod ) {
return false;
}
public TypeInfo getSchemaTypeInfo() { return this; }
public boolean isId( ) { return false; }
/**
* Associate an object to a key on this node. The object can later be
* retrieved from this node by calling <code>getUserData</code> with the
* same key.
* @param key The key to associate the object to.
* @param data The object to associate to the given key, or
* <code>null</code> to remove any existing association to that key.
* @param handler The handler to associate to that key, or
* <code>null</code>.
* @return Returns the <code>DOMObject</code> previously associated to
* the given key on this node, or <code>null</code> if there was none.
* @since DOM Level 3
*/
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
return getOwnerDocument().setUserData( key, data, handler);
}
/**
* Retrieves the object associated to a key on a this node. The object
* must first have been set to this node by calling
* <code>setUserData</code> with the same key.
* @param key The key the object is associated to.
* @return Returns the <code>DOMObject</code> associated to the given key
* on this node, or <code>null</code> if there was none.
* @since DOM Level 3
*/
public Object getUserData(String key) {
return getOwnerDocument().getUserData( key);
}
/**
* This method returns a specialized object which implements the
* specialized APIs of the specified feature and version. The
* specialized object may also be obtained by using binding-specific
* casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations.
* @param feature The name of the feature requested (case-insensitive).
* @param version This is the version number of the feature to test. If
* the version is <code>null</code> or the empty string, supporting
* any version of the feature will cause the method to return an
* object that supports at least one version of the feature.
* @return Returns an object which implements the specialized APIs of
* the specified feature and version, if any, or <code>null</code> if
* there is no object which implements interfaces associated with that
* feature. If the <code>DOMObject</code> returned by this method
* implements the <code>Node</code> interface, it must delegate to the
* primary core <code>Node</code> and not return results inconsistent
* with the primary core <code>Node</code> such as attributes,
* childNodes, etc.
* @since DOM Level 3
*/
public Object getFeature(String feature, String version) {
// we don't have any alternate node, either this node does the job
// or we don't have anything that does
return isSupported(feature, version) ? this : null;
}
/**
* Tests whether two nodes are equal.
* <br>This method tests for equality of nodes, not sameness (i.e.,
* whether the two nodes are references to the same object) which can be
* tested with <code>Node.isSameNode</code>. All nodes that are the same
* will also be equal, though the reverse may not be true.
* <br>Two nodes are equal if and only if the following conditions are
* satisfied: The two nodes are of the same type.The following string
* attributes are equal: <code>nodeName</code>, <code>localName</code>,
* <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
* , <code>baseURI</code>. This is: they are both <code>null</code>, or
* they have the same length and are character for character identical.
* The <code>attributes</code> <code>NamedNodeMaps</code> are equal.
* This is: they are both <code>null</code>, or they have the same
* length and for each node that exists in one map there is a node that
* exists in the other map and is equal, although not necessarily at the
* same index.The <code>childNodes</code> <code>NodeLists</code> are
* equal. This is: they are both <code>null</code>, or they have the
* same length and contain equal nodes at the same index. This is true
* for <code>Attr</code> nodes as for any other type of node. Note that
* normalization can affect equality; to avoid this, nodes should be
* normalized before being compared.
* <br>For two <code>DocumentType</code> nodes to be equal, the following
* conditions must also be satisfied: The following string attributes
* are equal: <code>publicId</code>, <code>systemId</code>,
* <code>internalSubset</code>.The <code>entities</code>
* <code>NamedNodeMaps</code> are equal.The <code>notations</code>
* <code>NamedNodeMaps</code> are equal.
* <br>On the other hand, the following do not affect equality: the
* <code>ownerDocument</code> attribute, the <code>specified</code>
* attribute for <code>Attr</code> nodes, the
* <code>isWhitespaceInElementContent</code> attribute for
* <code>Text</code> nodes, as well as any user data or event listeners
* registered on the nodes.
* @param arg The node to compare equality with.
* @param deep If <code>true</code>, recursively compare the subtrees; if
* <code>false</code>, compare only the nodes themselves (and its
* attributes, if it is an <code>Element</code>).
* @return If the nodes, and possibly subtrees are equal,
* <code>true</code> otherwise <code>false</code>.
* @since DOM Level 3
*/
public boolean isEqualNode(Node arg) {
if (arg == this) {
return true;
}
if (arg.getNodeType() != getNodeType()) {
return false;
}
// in theory nodeName can't be null but better be careful
// who knows what other implementations may be doing?...
if (getNodeName() == null) {
if (arg.getNodeName() != null) {
return false;
}
}
else if (!getNodeName().equals(arg.getNodeName())) {
return false;
}
if (getLocalName() == null) {
if (arg.getLocalName() != null) {
return false;
}
}
else if (!getLocalName().equals(arg.getLocalName())) {
return false;
}
if (getNamespaceURI() == null) {
if (arg.getNamespaceURI() != null) {
return false;
}
}
else if (!getNamespaceURI().equals(arg.getNamespaceURI())) {
return false;
}
if (getPrefix() == null) {
if (arg.getPrefix() != null) {
return false;
}
}
else if (!getPrefix().equals(arg.getPrefix())) {
return false;
}
if (getNodeValue() == null) {
if (arg.getNodeValue() != null) {
return false;
}
}
else if (!getNodeValue().equals(arg.getNodeValue())) {
return false;
}
/*
if (getBaseURI() == null) {
if (((NodeImpl) arg).getBaseURI() != null) {
return false;
}
}
else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) {
return false;
}
*/
return true;
}
/**
* DOM Level 3 - Experimental:
* Look up the namespace URI associated to the given prefix, starting from this node.
* Use lookupNamespaceURI(null) to lookup the default namespace
*
* @param namespaceURI
* @return th URI for the namespace
* @since DOM Level 3
*/
public String lookupNamespaceURI(String specifiedPrefix) {
short type = this.getNodeType();
switch (type) {
case Node.ELEMENT_NODE : {
String namespace = this.getNamespaceURI();
String prefix = this.getPrefix();
if (namespace !=null) {
// REVISIT: is it possible that prefix is empty string?
if (specifiedPrefix== null && prefix==specifiedPrefix) {
// looking for default namespace
return namespace;
} else if (prefix != null && prefix.equals(specifiedPrefix)) {
// non default namespace
return namespace;
}
}
if (this.hasAttributes()) {
NamedNodeMap map = this.getAttributes();
int length = map.getLength();
for (int i=0;i<length;i++) {
Node attr = map.item(i);
String attrPrefix = attr.getPrefix();
String value = attr.getNodeValue();
namespace = attr.getNamespaceURI();
if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
// at this point we are dealing with DOM Level 2 nodes only
if (specifiedPrefix == null &&
attr.getNodeName().equals("xmlns")) {
// default namespace
return value;
} else if (attrPrefix !=null &&
attrPrefix.equals("xmlns") &&
attr.getLocalName().equals(specifiedPrefix)) {
// non default namespace
return value;
}
}
}
}
/*
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.lookupNamespaceURI(specifiedPrefix);
}
*/
return null;
}
/*
case Node.DOCUMENT_NODE : {
return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ;
}
*/
case Node.ENTITY_NODE :
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
// type is unknown
return null;
case Node.ATTRIBUTE_NODE:{
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
}
return null;
}
default:{
/*
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.lookupNamespaceURI(specifiedPrefix);
}
*/
return null;
}
}
}
/**
* DOM Level 3: Experimental
* This method checks if the specified <code>namespaceURI</code> is the
* default namespace or not.
* @param namespaceURI The namespace URI to look for.
* @return <code>true</code> if the specified <code>namespaceURI</code>
* is the default namespace, <code>false</code> otherwise.
* @since DOM Level 3
*/
public boolean isDefaultNamespace(String namespaceURI){
/*
// REVISIT: remove casts when DOM L3 becomes REC.
short type = this.getNodeType();
switch (type) {
case Node.ELEMENT_NODE: {
String namespace = this.getNamespaceURI();
String prefix = this.getPrefix();
// REVISIT: is it possible that prefix is empty string?
if (prefix == null || prefix.length() == 0) {
if (namespaceURI == null) {
return (namespace == namespaceURI);
}
return namespaceURI.equals(namespace);
}
if (this.hasAttributes()) {
ElementImpl elem = (ElementImpl)this;
NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns");
if (attr != null) {
String value = attr.getNodeValue();
if (namespaceURI == null) {
return (namespace == value);
}
return namespaceURI.equals(value);
}
}
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.isDefaultNamespace(namespaceURI);
}
return false;
}
case Node.DOCUMENT_NODE:{
return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI);
}
case Node.ENTITY_NODE :
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
// type is unknown
return false;
case Node.ATTRIBUTE_NODE:{
if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) {
return ownerNode.isDefaultNamespace(namespaceURI);
}
return false;
}
default:{
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.isDefaultNamespace(namespaceURI);
}
return false;
}
}
*/
return false;
}
/**
*
* DOM Level 3 - Experimental:
* Look up the prefix associated to the given namespace URI, starting from this node.
*
* @param namespaceURI
* @return the prefix for the namespace
*/
public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true
// Prefix can't be bound to null namespace
if (namespaceURI == null) {
return null;
}
short type = this.getNodeType();
switch (type) {
/*
case Node.ELEMENT_NODE: {
String namespace = this.getNamespaceURI(); // to flip out children
return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);
}
case Node.DOCUMENT_NODE:{
return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);
}
*/
case Node.ENTITY_NODE :
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
// type is unknown
return null;
case Node.ATTRIBUTE_NODE:{
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
}
return null;
}
default:{
/*
NodeImpl ancestor = (NodeImpl)getElementAncestor(this);
if (ancestor != null) {
return ancestor.lookupPrefix(namespaceURI);
}
*/
return null;
}
}
}
/**
* Returns whether this node is the same node as the given one.
* <br>This method provides a way to determine whether two
* <code>Node</code> references returned by the implementation reference
* the same object. When two <code>Node</code> references are references
* to the same object, even if through a proxy, the references may be
* used completely interchangably, such that all attributes have the
* same values and calling the same DOM method on either reference
* always has exactly the same effect.
* @param other The node to test against.
* @return Returns <code>true</code> if the nodes are the same,
* <code>false</code> otherwise.
* @since DOM Level 3
*/
public boolean isSameNode(Node other) {
// we do not use any wrapper so the answer is obvious
return this == other;
}
/**
* This attribute returns the text content of this node and its
* descendants. When it is defined to be null, setting it has no effect.
* When set, any possible children this node may have are removed and
* replaced by a single <code>Text</code> node containing the string
* this attribute is set to. On getting, no serialization is performed,
* the returned string does not contain any markup. No whitespace
* normalization is performed, the returned string does not contain the
* element content whitespaces . Similarly, on setting, no parsing is
* performed either, the input string is taken as pure textual content.
* <br>The string returned is made of the text content of this node
* depending on its type, as defined below:
* <table border='1'>
* <tr>
* <th>Node type</th>
* <th>Content</th>
* </tr>
* <tr>
* <td valign='top' rowspan='1' colspan='1'>
* ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
* DOCUMENT_FRAGMENT_NODE</td>
* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
* attribute value of every child node, excluding COMMENT_NODE and
* PROCESSING_INSTRUCTION_NODE nodes</td>
* </tr>
* <tr>
* <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
* CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
* <td valign='top' rowspan='1' colspan='1'>
* <code>nodeValue</code></td>
* </tr>
* <tr>
* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
* <td valign='top' rowspan='1' colspan='1'>
* null</td>
* </tr>
* </table>
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
* @exception DOMException
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
* @since DOM Level 3
*/
public void setTextContent(String textContent)
throws DOMException {
setNodeValue(textContent);
}
/**
* This attribute returns the text content of this node and its
* descendants. When it is defined to be null, setting it has no effect.
* When set, any possible children this node may have are removed and
* replaced by a single <code>Text</code> node containing the string
* this attribute is set to. On getting, no serialization is performed,
* the returned string does not contain any markup. No whitespace
* normalization is performed, the returned string does not contain the
* element content whitespaces . Similarly, on setting, no parsing is
* performed either, the input string is taken as pure textual content.
* <br>The string returned is made of the text content of this node
* depending on its type, as defined below:
* <table border='1'>
* <tr>
* <th>Node type</th>
* <th>Content</th>
* </tr>
* <tr>
* <td valign='top' rowspan='1' colspan='1'>
* ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
* DOCUMENT_FRAGMENT_NODE</td>
* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
* attribute value of every child node, excluding COMMENT_NODE and
* PROCESSING_INSTRUCTION_NODE nodes</td>
* </tr>
* <tr>
* <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
* CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
* <td valign='top' rowspan='1' colspan='1'>
* <code>nodeValue</code></td>
* </tr>
* <tr>
* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
* <td valign='top' rowspan='1' colspan='1'>
* null</td>
* </tr>
* </table>
* @exception DOMException
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
* @exception DOMException
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
* @since DOM Level 3
*/
public String getTextContent() throws DOMException {
return getNodeValue(); // overriden in some subclasses
}
/**
* Compares a node with this node with regard to their position in the
* document.
* @param other The node to compare against this node.
* @return Returns how the given node is positioned relatively to this
* node.
* @since DOM Level 3
*/
public short compareDocumentPosition(Node other) throws DOMException {
return 0;
}
/**
* The absolute base URI of this node or <code>null</code> if undefined.
* This value is computed according to . However, when the
* <code>Document</code> supports the feature "HTML" , the base URI is
* computed using first the value of the href attribute of the HTML BASE
* element if any, and the value of the <code>documentURI</code>
* attribute from the <code>Document</code> interface otherwise.
* <br> When the node is an <code>Element</code>, a <code>Document</code>
* or a a <code>ProcessingInstruction</code>, this attribute represents
* the properties [base URI] defined in . When the node is a
* <code>Notation</code>, an <code>Entity</code>, or an
* <code>EntityReference</code>, this attribute represents the
* properties [declaration base URI] in the . How will this be affected
* by resolution of relative namespace URIs issue?It's not.Should this
* only be on Document, Element, ProcessingInstruction, Entity, and
* Notation nodes, according to the infoset? If not, what is it equal to
* on other nodes? Null? An empty string? I think it should be the
* parent's.No.Should this be read-only and computed or and actual
* read-write attribute?Read-only and computed (F2F 19 Jun 2000 and
* teleconference 30 May 2001).If the base HTML element is not yet
* attached to a document, does the insert change the Document.baseURI?
* Yes. (F2F 26 Sep 2001)
* @since DOM Level 3
*/
public String getBaseURI() {
return null;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,363 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.dtm.ref.sax2dtm;
import javax.xml.transform.Source;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMManager;
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
import com.sun.org.apache.xml.internal.utils.IntStack;
import com.sun.org.apache.xml.internal.utils.IntVector;
import com.sun.org.apache.xml.internal.utils.StringVector;
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
import org.xml.sax.SAXException;
/**
* This is a subclass of SAX2DTM which has been modified to meet the needs of
* Result Tree Frameworks (RTFs). The differences are:
*
* 1) Multiple XML trees may be appended to the single DTM. This means
* that the root node of each document is _not_ node 0. Some code has
* had to be deoptimized to support this mode of operation, and an
* explicit mechanism for obtaining the Node Handle of the root node
* has been provided.
*
* 2) A stack of these documents is maintained, allowing us to "tail-prune" the
* most recently added trees off the end of the DTM as stylesheet elements
* (and thus variable contexts) are exited.
*
* PLEASE NOTE that this class may be _heavily_ dependent upon the
* internals of the SAX2DTM superclass, and must be maintained in
* parallel with that code. Arguably, they should be conditionals
* within a single class... but they have deen separated for
* performance reasons. (In fact, one could even argue about which is
* the superclass and which is the subclass; the current arrangement
* is as much about preserving stability of existing code during
* development as anything else.)
*
* %REVIEW% In fact, since the differences are so minor, I think it
* may be possible/practical to fold them back into the base
* SAX2DTM. Consider that as a future code-size optimization.
* */
public class SAX2RTFDTM extends SAX2DTM
{
/** Set true to monitor SAX events and similar diagnostic info. */
private static final boolean DEBUG = false;
/** Most recently started Document, or null if the DTM is empty. */
private int m_currentDocumentNode=NULL;
/** Tail-pruning mark: Number of nodes in use */
IntStack mark_size=new IntStack();
/** Tail-pruning mark: Number of data items in use */
IntStack mark_data_size=new IntStack();
/** Tail-pruning mark: Number of size-of-data fields in use */
IntStack mark_char_size=new IntStack();
/** Tail-pruning mark: Number of dataOrQName slots in use */
IntStack mark_doq_size=new IntStack();
/** Tail-pruning mark: Number of namespace declaration sets in use
* %REVIEW% I don't think number of NS sets is ever different from number
* of NS elements. We can probabably reduce these to a single stack and save
* some storage.
* */
IntStack mark_nsdeclset_size=new IntStack();
/** Tail-pruning mark: Number of naespace declaration elements in use
* %REVIEW% I don't think number of NS sets is ever different from number
* of NS elements. We can probabably reduce these to a single stack and save
* some storage.
*/
IntStack mark_nsdeclelem_size=new IntStack();
/**
* Tail-pruning mark: initial number of nodes in use
*/
int m_emptyNodeCount;
/**
* Tail-pruning mark: initial number of namespace declaration sets
*/
int m_emptyNSDeclSetCount;
/**
* Tail-pruning mark: initial number of namespace declaration elements
*/
int m_emptyNSDeclSetElemsCount;
/**
* Tail-pruning mark: initial number of data items in use
*/
int m_emptyDataCount;
/**
* Tail-pruning mark: initial number of characters in use
*/
int m_emptyCharsCount;
/**
* Tail-pruning mark: default initial number of dataOrQName slots in use
*/
int m_emptyDataQNCount;
public SAX2RTFDTM(DTMManager mgr, Source source, int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing)
{
super(mgr, source, dtmIdentity, whiteSpaceFilter,
xstringfactory, doIndexing);
// NEVER track source locators for RTFs; they aren't meaningful. I think.
// (If we did track them, we'd need to tail-prune these too.)
//com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl.m_source_location;
m_useSourceLocationProperty=false;
m_sourceSystemId = (m_useSourceLocationProperty) ? new StringVector()
: null;
m_sourceLine = (m_useSourceLocationProperty) ? new IntVector() : null;
m_sourceColumn = (m_useSourceLocationProperty) ? new IntVector() : null;
// Record initial sizes of fields that are pushed and restored
// for RTF tail-pruning. More entries can be popped than pushed, so
// we need this to mark the primordial state of the DTM.
m_emptyNodeCount = m_size;
m_emptyNSDeclSetCount = (m_namespaceDeclSets == null)
? 0 : m_namespaceDeclSets.size();
m_emptyNSDeclSetElemsCount = (m_namespaceDeclSetElements == null)
? 0 : m_namespaceDeclSetElements.size();
m_emptyDataCount = m_data.size();
m_emptyCharsCount = m_chars.size();
m_emptyDataQNCount = m_dataOrQName.size();
}
/**
* Given a DTM, find the owning document node. In the case of
* SAX2RTFDTM, which may contain multiple documents, this returns
* the <b>most recently started</b> document, or null if the DTM is
* empty or no document is currently under construction.
*
* %REVIEW% Should we continue to report the most recent after
* construction has ended? I think not, given that it may have been
* tail-pruned.
*
* @return int Node handle of Document node, or null if this DTM does not
* contain an "active" document.
* */
public int getDocument()
{
return makeNodeHandle(m_currentDocumentNode);
}
/**
* Given a node handle, find the owning document node, using DTM semantics
* (Document owns itself) rather than DOM semantics (Document has no owner).
*
* (I'm counting on the fact that getOwnerDocument() is implemented on top
* of this call, in the superclass, to avoid having to rewrite that one.
* Be careful if that code changes!)
*
* @param nodeHandle the id of the node.
* @return int Node handle of owning document
*/
public int getDocumentRoot(int nodeHandle)
{
for (int id=makeNodeIdentity(nodeHandle); id!=NULL; id=_parent(id)) {
if (_type(id)==DTM.DOCUMENT_NODE) {
return makeNodeHandle(id);
}
}
return DTM.NULL; // Safety net; should never happen
}
/**
* Given a node identifier, find the owning document node. Unlike the DOM,
* this considers the owningDocument of a Document to be itself. Note that
* in shared DTMs this may not be zero.
*
* @param nodeIdentifier the id of the starting node.
* @return int Node identifier of the root of this DTM tree
*/
protected int _documentRoot(int nodeIdentifier)
{
if(nodeIdentifier==NULL) return NULL;
for (int parent=_parent(nodeIdentifier);
parent!=NULL;
nodeIdentifier=parent,parent=_parent(nodeIdentifier))
;
return nodeIdentifier;
}
/**
* Receive notification of the beginning of a new RTF document.
*
* %REVIEW% Y'know, this isn't all that much of a deoptimization. We
* might want to consider folding the start/endDocument changes back
* into the main SAX2DTM so we don't have to expose so many fields
* (even as Protected) and carry the additional code.
*
* @throws SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ContentHandler#startDocument
* */
public void startDocument() throws SAXException
{
// Re-initialize the tree append process
m_endDocumentOccured = false;
m_prefixMappings = new java.util.Vector();
m_contextIndexes = new IntStack();
m_parents = new IntStack();
m_currentDocumentNode=m_size;
super.startDocument();
}
/**
* Receive notification of the end of the document.
*
* %REVIEW% Y'know, this isn't all that much of a deoptimization. We
* might want to consider folding the start/endDocument changes back
* into the main SAX2DTM so we don't have to expose so many fields
* (even as Protected).
*
* @throws SAXException Any SAX exception, possibly
* wrapping another exception.
* @see org.xml.sax.ContentHandler#endDocument
* */
public void endDocument() throws SAXException
{
charactersFlush();
m_nextsib.setElementAt(NULL,m_currentDocumentNode);
if (m_firstch.elementAt(m_currentDocumentNode) == NOTPROCESSED)
m_firstch.setElementAt(NULL,m_currentDocumentNode);
if (DTM.NULL != m_previous)
m_nextsib.setElementAt(DTM.NULL,m_previous);
m_parents = null;
m_prefixMappings = null;
m_contextIndexes = null;
m_currentDocumentNode= NULL; // no longer open
m_endDocumentOccured = true;
}
/** "Tail-pruning" support for RTFs.
*
* This function pushes information about the current size of the
* DTM's data structures onto a stack, for use by popRewindMark()
* (which see).
*
* %REVIEW% I have no idea how to rewind m_elemIndexes. However,
* RTFs will not be indexed, so I can simply panic if that case
* arises. Hey, it works...
* */
public void pushRewindMark()
{
if(m_indexing || m_elemIndexes!=null)
throw new java.lang.NullPointerException("Coding error; Don't try to mark/rewind an indexed DTM");
// Values from DTMDefaultBase
// %REVIEW% Can the namespace stack sizes ever differ? If not, save space!
mark_size.push(m_size);
mark_nsdeclset_size.push((m_namespaceDeclSets==null)
? 0
: m_namespaceDeclSets.size());
mark_nsdeclelem_size.push((m_namespaceDeclSetElements==null)
? 0
: m_namespaceDeclSetElements.size());
// Values from SAX2DTM
mark_data_size.push(m_data.size());
mark_char_size.push(m_chars.size());
mark_doq_size.push(m_dataOrQName.size());
}
/** "Tail-pruning" support for RTFs.
*
* This function pops the information previously saved by
* pushRewindMark (which see) and uses it to discard all nodes added
* to the DTM after that time. We expect that this will allow us to
* reuse storage more effectively.
*
* This is _not_ intended to be called while a document is still being
* constructed -- only between endDocument and the next startDocument
*
* %REVIEW% WARNING: This is the first use of some of the truncation
* methods. If Xalan blows up after this is called, that's a likely
* place to check.
*
* %REVIEW% Our original design for DTMs permitted them to share
* string pools. If there any risk that this might be happening, we
* can _not_ rewind and recover the string storage. One solution
* might to assert that DTMs used for RTFs Must Not take advantage
* of that feature, but this seems excessively fragile. Another, much
* less attractive, would be to just let them leak... Nah.
*
* @return true if and only if the pop completely emptied the
* RTF. That response is used when determining how to unspool
* RTF-started-while-RTF-open situations.
* */
public boolean popRewindMark()
{
boolean top=mark_size.empty();
m_size=top ? m_emptyNodeCount : mark_size.pop();
m_exptype.setSize(m_size);
m_firstch.setSize(m_size);
m_nextsib.setSize(m_size);
m_prevsib.setSize(m_size);
m_parent.setSize(m_size);
m_elemIndexes=null;
int ds= top ? m_emptyNSDeclSetCount : mark_nsdeclset_size.pop();
if (m_namespaceDeclSets!=null) {
m_namespaceDeclSets.setSize(ds);
}
int ds1= top ? m_emptyNSDeclSetElemsCount : mark_nsdeclelem_size.pop();
if (m_namespaceDeclSetElements!=null) {
m_namespaceDeclSetElements.setSize(ds1);
}
// Values from SAX2DTM - m_data always has a reserved entry
m_data.setSize(top ? m_emptyDataCount : mark_data_size.pop());
m_chars.setLength(top ? m_emptyCharsCount : mark_char_size.pop());
m_dataOrQName.setSize(top ? m_emptyDataQNCount : mark_doq_size.pop());
// Return true iff DTM now empty
return m_size==0;
}
/** @return true if a DTM tree is currently under construction.
* */
public boolean isTreeIncomplete()
{
return !m_endDocumentOccured;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Function not supported!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Cannot overwrite cause"},
{ ER_NO_DEFAULT_IMPL,
"No default implementation found "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) not currently supported"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Offset bigger than slot"},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine not available, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager received co_exit() request"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() failed"},
{ ER_COROUTINE_PARAM,
"Coroutine parameter error ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nUNEXPECTED: Parser doTerminate answers {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"parse may not be called while parsing"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Error: typed iterator for axis {0} not implemented"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Error: iterator for axis {0} not implemented "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Iterator clone not supported"},
{ ER_UNKNOWN_AXIS_TYPE,
"Unknown axis traversal type: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Axis traverser not supported: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"No more DTM IDs are available"},
{ ER_NOT_SUPPORTED,
"Not supported: {0}"},
{ ER_NODE_NON_NULL,
"Node must be non-null for getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Could not resolve the node to a handle"},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse may not be called while parsing"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse needs a non-null SAXParser"},
{ ER_COULD_NOT_INIT_PARSER,
"could not initialize parser with"},
{ ER_EXCEPTION_CREATING_POOL,
"exception creating new instance for pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Path contains invalid escape sequence"},
{ ER_SCHEME_REQUIRED,
"Scheme is required!"},
{ ER_NO_SCHEME_IN_URI,
"No scheme found in URI: {0}"},
{ ER_NO_SCHEME_INURI,
"No scheme found in URI"},
{ ER_PATH_INVALID_CHAR,
"Path contains invalid character: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Cannot set scheme from null string"},
{ ER_SCHEME_NOT_CONFORMANT,
"The scheme is not conformant."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Host is not a well formed address"},
{ ER_PORT_WHEN_HOST_NULL,
"Port cannot be set when host is null"},
{ ER_INVALID_PORT,
"Invalid port number"},
{ ER_FRAG_FOR_GENERIC_URI,
"Fragment can only be set for a generic URI"},
{ ER_FRAG_WHEN_PATH_NULL,
"Fragment cannot be set when path is null"},
{ ER_FRAG_INVALID_CHAR,
"Fragment contains invalid character"},
{ ER_PARSER_IN_USE,
"Parser is already in use"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"Cannot change {0} {1} while parsing"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Self-causation not permitted"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Userinfo may not be specified if host is not specified"},
{ ER_NO_PORT_IF_NO_HOST,
"Port may not be specified if host is not specified"},
{ ER_NO_QUERY_STRING_IN_PATH,
"Query string cannot be specified in path and query string"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Fragment cannot be specified in both the path and fragment"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"Cannot initialize URI with empty parameters"},
{ ER_METHOD_NOT_SUPPORTED,
"Method not yet supported "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter not currently restartable"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader not before startParse request"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Axis traverser not supported: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler created with null PrintWriter!"},
{ ER_SYSTEMID_UNKNOWN,
"SystemId Unknown"},
{ ER_LOCATION_UNKNOWN,
"Location of error unknown"},
{ ER_PREFIX_MUST_RESOLVE,
"Prefix must resolve to a namespace: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() not supported in XPathContext!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"Attribute child does not have an owner document!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"Attribute child does not have an owner document element!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Warning: can't output text before document element! Ignoring..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"Can't have more than one root on a DOM!"},
{ ER_ARG_LOCALNAME_NULL,
"Argument 'localName' is null"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Localname in QNAME should be a valid NCName"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"Prefix in QNAME should be a valid NCName"},
{ ER_NAME_CANT_START_WITH_COLON,
"Name cannot start with a colon"},
{ "BAD_CODE", "Parameter to createMessage was out of bounds"},
{ "FORMAT_FAILED", "Exception thrown during messageFormat call"},
{ "line", "Line #"},
{ "column","Column #"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"The serializer class ''{0}'' does not implement org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"The resource [ {0} ] could not be found.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"The resource [ {0} ] could not load: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Buffer size <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Invalid UTF-16 surrogate detected: {0} ?" },
{ER_OIERROR,
"IO error" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Cannot add attribute {0} after child nodes or before an element is produced. Attribute will be ignored."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"Namespace for prefix ''{0}'' has not been declared." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Attribute ''{0}'' outside of element." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Namespace declaration ''{0}''=''{1}'' outside of element." },
{ER_COULD_NOT_LOAD_RESOURCE,
"Could not load ''{0}'' (check CLASSPATH), now using just the defaults"},
{ ER_ILLEGAL_CHARACTER,
"Attempt to output character of integral value {0} that is not represented in specified output encoding of {1}."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Could not load the propery file ''{0}'' for output method ''{1}'' (check CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,442 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_ca extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
private static final Object[][] _contents = new Object[][] {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Aquesta funci\u00f3 no t\u00e9 suport. "},
{ ER_CANNOT_OVERWRITE_CAUSE,
"No es pot sobreescriure una causa "},
{ ER_NO_DEFAULT_IMPL,
"No s'ha trobat cap implementaci\u00f3 per defecte "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"En l''actualitat ChunkedIntArray({0}) no t\u00e9 suport "},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"El despla\u00e7ament \u00e9s m\u00e9s gran que la ranura "},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine no est\u00e0 disponible, id={0} "},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager ha rebut una petici\u00f3 co_exit() "},
{ ER_COJOINROUTINESET_FAILED,
"S'ha produ\u00eft un error a co_joinCoroutineSet() "},
{ ER_COROUTINE_PARAM,
"Error de par\u00e0metre coroutine ({0}) "},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nUNEXPECTED: doTerminate de l''analitzador respon {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"L'an\u00e0lisi no es pot cridar mentre s'est\u00e0 duent a terme "},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Error: l''iterador de tipus de l''eix {0} no s''ha implementat "},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Error: l''iterador de l''eix {0} no s''ha implementat "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"El clonatge de l'iterador no t\u00e9 suport "},
{ ER_UNKNOWN_AXIS_TYPE,
"Tipus de commutaci\u00f3 de l''eix desconeguda: {0} "},
{ ER_AXIS_NOT_SUPPORTED,
"La commutaci\u00f3 de l''eix no t\u00e9 suport: {0} "},
{ ER_NO_DTMIDS_AVAIL,
"No hi ha m\u00e9s ID de DTM disponibles "},
{ ER_NOT_SUPPORTED,
"No t\u00e9 suport: {0} "},
{ ER_NODE_NON_NULL,
"El node no ha de ser nul per a getDTMHandleFromNode "},
{ ER_COULD_NOT_RESOLVE_NODE,
"No s'ha pogut resoldre el node en un manejador "},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse no es pot cridar mentre s'est\u00e0 duent a terme l'an\u00e0lisi "},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse necessita un SAXParser que no sigui nul "},
{ ER_COULD_NOT_INIT_PARSER,
"No s'ha pogut inicialitzar l'analitzador amb "},
{ ER_EXCEPTION_CREATING_POOL,
"S'ha produ\u00eft una excepci\u00f3 en crear una nova inst\u00e0ncia de l'agrupaci\u00f3 "},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"La via d'acc\u00e9s cont\u00e9 una seq\u00fc\u00e8ncia d'escapament no v\u00e0lida "},
{ ER_SCHEME_REQUIRED,
"Es necessita l'esquema "},
{ ER_NO_SCHEME_IN_URI,
"No s''ha trobat cap esquema a l''URI: {0} "},
{ ER_NO_SCHEME_INURI,
"No s'ha trobat cap esquema a l'URI "},
{ ER_PATH_INVALID_CHAR,
"La via d'acc\u00e9s cont\u00e9 un car\u00e0cter no v\u00e0lid {0} "},
{ ER_SCHEME_FROM_NULL_STRING,
"No es pot establir un esquema des d'una cadena nul\u00b7la "},
{ ER_SCHEME_NOT_CONFORMANT,
"L'esquema no t\u00e9 conformitat. "},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"El sistema principal no t\u00e9 una adre\u00e7a ben formada "},
{ ER_PORT_WHEN_HOST_NULL,
"El port no es pot establir quan el sistema principal \u00e9s nul "},
{ ER_INVALID_PORT,
"N\u00famero de port no v\u00e0lid "},
{ ER_FRAG_FOR_GENERIC_URI,
"El fragment nom\u00e9s es pot establir per a un URI gen\u00e8ric "},
{ ER_FRAG_WHEN_PATH_NULL,
"El fragment no es pot establir si la via d'acc\u00e9s \u00e9s nul\u00b7la "},
{ ER_FRAG_INVALID_CHAR,
"El fragment cont\u00e9 un car\u00e0cter no v\u00e0lid "},
{ ER_PARSER_IN_USE,
"L'analitzador ja s'est\u00e0 utilitzant "},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"No es pot modificar {0} {1} mentre es du a terme l''an\u00e0lisi "},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"La causalitat pr\u00f2pia no est\u00e0 permesa. "},
{ ER_NO_USERINFO_IF_NO_HOST,
"No es pot especificar informaci\u00f3 de l'usuari si no s'especifica el sistema principal "},
{ ER_NO_PORT_IF_NO_HOST,
"No es pot especificar el port si no s'especifica el sistema principal "},
{ ER_NO_QUERY_STRING_IN_PATH,
"No es pot especificar una cadena de consulta en la via d'acc\u00e9s i la cadena de consulta "},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"No es pot especificar un fragment tant en la via d'acc\u00e9s com en el fragment "},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"No es pot inicialitzar l'URI amb par\u00e0metres buits "},
{ ER_METHOD_NOT_SUPPORTED,
"Aquest m\u00e8tode encara no t\u00e9 suport "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"Ara mateix no es pot reiniciar IncrementalSAXSource_Filter "},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader no es pot produir abans de la petici\u00f3 d'startParse "},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"La commutaci\u00f3 de l''eix no t\u00e9 suport: {0} "},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"S''ha creat ListingErrorHandler amb PrintWriter nul "},
{ ER_SYSTEMID_UNKNOWN,
"ID del sistema (SystemId) desconegut "},
{ ER_LOCATION_UNKNOWN,
"Ubicaci\u00f3 de l'error desconeguda"},
{ ER_PREFIX_MUST_RESOLVE,
"El prefix s''ha de resoldre en un espai de noms: {0} "},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() no t\u00e9 suport a XPathContext "},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"El subordinat de l'atribut no t\u00e9 un document de propietari. "},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"El subordinat de l'atribut no t\u00e9 un element de document de propietari. "},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Av\u00eds: no es pot produir text abans de l'element de document. Es passa per alt. "},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"No hi pot haver m\u00e9s d'una arrel en un DOM. "},
{ ER_ARG_LOCALNAME_NULL,
"L'argument 'localName' \u00e9s nul. "},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"El nom local de QNAME ha de ser un NCName v\u00e0lid. "},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"El prefix de QNAME ha de ser un NCName v\u00e0lid. "},
{ "BAD_CODE", "El par\u00e0metre de createMessage estava fora dels l\u00edmits. "},
{ "FORMAT_FAILED", "S'ha generat una excepci\u00f3 durant la crida messageFormat. "},
{ "line", "L\u00ednia n\u00fam. "},
{ "column","Columna n\u00fam. "},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"La classe de serialitzador ''{0}'' no implementa org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"No s''ha trobat el recurs [ {0} ].\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"El recurs [ {0} ] no s''ha pogut carregar: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Grand\u00e0ria del buffer <=0 " },
{ER_INVALID_UTF16_SURROGATE,
"S''ha detectat un suplent UTF-16 no v\u00e0lid: {0} ? " },
{ER_OIERROR,
"Error d'E/S " },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"No es pot afegir l''atribut {0} despr\u00e9s dels nodes subordinats o abans que es produeixi un element. Es passar\u00e0 per alt l''atribut. "},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"L''espai de noms del prefix ''{0}'' no s''ha declarat." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"L''atribut ''{0}'' es troba fora de l''element." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"La declaraci\u00f3 d''espai de noms ''{0}''=''{1}'' es troba fora de l''element." },
{ER_COULD_NOT_LOAD_RESOURCE,
"No s''ha pogut carregar ''{0}'' (comproveu la CLASSPATH); ara s''estan fent servir els valors per defecte."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"No s''ha pogut carregar el fitxer de propietats ''{0}'' del m\u00e8tode de sortida ''{1}'' (comproveu la CLASSPATH)" }
};
/**
* Get the lookup table for error messages
*
* @return The association list.
*/
public Object[][] getContents()
{
return _contents;
}
}

View File

@@ -0,0 +1,442 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_cs extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
private static final Object[][] _contents = new Object[][] {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Nepodporovan\u00e1 funkce!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"P\u0159\u00ed\u010dinu nelze p\u0159epsat"},
{ ER_NO_DEFAULT_IMPL,
"Nebyla nalezena v\u00fdchoz\u00ed implementace. "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"Funkce ChunkedIntArray({0}) nen\u00ed aktu\u00e1ln\u011b podporov\u00e1na."},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Offset je v\u011bt\u0161\u00ed ne\u017e slot."},
{ ER_COROUTINE_NOT_AVAIL,
"Spole\u010dn\u00e1 rutina nen\u00ed k dispozici, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"Funkce CoroutineManager obdr\u017eela po\u017eadavek co_exit()"},
{ ER_COJOINROUTINESET_FAILED,
"Selhala funkce co_joinCoroutineSet()"},
{ ER_COROUTINE_PARAM,
"Chyba parametru spole\u010dn\u00e9 rutiny ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nNeo\u010dek\u00e1van\u00e9: odpov\u011bdi funkce analyz\u00e1toru doTerminate {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"b\u011bhem anal\u00fdzy nelze volat analyz\u00e1tor"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Chyba: zadan\u00fd iter\u00e1tor osy {0} nen\u00ed implementov\u00e1n"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Chyba: zadan\u00fd iter\u00e1tor osy {0} nen\u00ed implementov\u00e1n "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Nepodporovan\u00fd klon iter\u00e1toru."},
{ ER_UNKNOWN_AXIS_TYPE,
"Nezn\u00e1m\u00fd typ osy pr\u016fchodu: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Nepodporovan\u00e1 osa pr\u016fchodu: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"\u017d\u00e1dn\u00e1 dal\u0161\u00ed ID DTM nejsou k dispozici"},
{ ER_NOT_SUPPORTED,
"Nepodporov\u00e1no: {0}"},
{ ER_NODE_NON_NULL,
"Uzel pou\u017eit\u00fd ve funkci getDTMHandleFromNode mus\u00ed m\u00edt hodnotu not-null"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Uzel nelze p\u0159elo\u017eit do manipul\u00e1toru"},
{ ER_STARTPARSE_WHILE_PARSING,
"B\u011bhem anal\u00fdzy nelze volat funkci startParse."},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"Funkce startParse vy\u017eaduje SAXParser s hodnotou not-null."},
{ ER_COULD_NOT_INIT_PARSER,
"nelze inicializovat analyz\u00e1tor s: "},
{ ER_EXCEPTION_CREATING_POOL,
"v\u00fdjimka p\u0159i vytv\u00e1\u0159en\u00ed nov\u00e9 instance spole\u010dn\u00e9 oblasti"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Cesta obsahuje neplatnou escape sekvenci"},
{ ER_SCHEME_REQUIRED,
"Je vy\u017eadov\u00e1no sch\u00e9ma!"},
{ ER_NO_SCHEME_IN_URI,
"V URI nebylo nalezeno \u017e\u00e1dn\u00e9 sch\u00e9ma: {0}"},
{ ER_NO_SCHEME_INURI,
"V URI nebylo nalezeno \u017e\u00e1dn\u00e9 sch\u00e9ma"},
{ ER_PATH_INVALID_CHAR,
"Cesta obsahuje neplatn\u00fd znak: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Nelze nastavit sch\u00e9ma \u0159et\u011bzce s hodnotou null."},
{ ER_SCHEME_NOT_CONFORMANT,
"Sch\u00e9ma nevyhovuje."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Adresa hostitele m\u00e1 nespr\u00e1vn\u00fd form\u00e1t."},
{ ER_PORT_WHEN_HOST_NULL,
"M\u00e1-li hostitel hodnotu null, nelze nastavit port."},
{ ER_INVALID_PORT,
"Neplatn\u00e9 \u010d\u00edslo portu."},
{ ER_FRAG_FOR_GENERIC_URI,
"Fragment lze nastavit jen u generick\u00e9ho URI."},
{ ER_FRAG_WHEN_PATH_NULL,
"M\u00e1-li cesta hodnotu null, nelze nastavit fragment."},
{ ER_FRAG_INVALID_CHAR,
"Fragment obsahuje neplatn\u00fd znak."},
{ ER_PARSER_IN_USE,
"Analyz\u00e1tor se ji\u017e pou\u017e\u00edv\u00e1."},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"B\u011bhem anal\u00fdzy nelze m\u011bnit {0} {1}."},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Zp\u016fsoben\u00ed sama sebe (self-causation) nen\u00ed povoleno"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Nen\u00ed-li ur\u010den hostitel, nelze zadat \u00fadaje o u\u017eivateli."},
{ ER_NO_PORT_IF_NO_HOST,
"Nen\u00ed-li ur\u010den hostitel, nelze zadat port."},
{ ER_NO_QUERY_STRING_IN_PATH,
"V \u0159et\u011bzci cesty a dotazu nelze zadat \u0159et\u011bzec dotazu."},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Fragment nelze ur\u010dit z\u00e1rove\u0148 v cest\u011b i ve fragmentu."},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"URI nelze inicializovat s pr\u00e1zdn\u00fdmi parametry."},
{ ER_METHOD_NOT_SUPPORTED,
"Prozat\u00edm nepodporovan\u00e1 metoda. "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"Filtr IncrementalSAXSource_Filter nelze aktu\u00e1ln\u011b znovu spustit."},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"P\u0159ed po\u017eadavkem startParse nen\u00ed XMLReader."},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Nepodporovan\u00e1 osa pr\u016fchodu: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"Prvek ListingErrorHandler byl vytvo\u0159en s funkc\u00ed PrintWriter s hodnotou null!"},
{ ER_SYSTEMID_UNKNOWN,
"Nezn\u00e1m\u00fd identifik\u00e1tor SystemId"},
{ ER_LOCATION_UNKNOWN,
"Chyba se vyskytla na nezn\u00e1m\u00e9m m\u00edst\u011b"},
{ ER_PREFIX_MUST_RESOLVE,
"P\u0159edponu mus\u00ed b\u00fdt mo\u017eno p\u0159elo\u017eit do oboru n\u00e1zv\u016f: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"Funkce XPathContext nepodporuje funkci createDocument()!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"Potomek atributu nem\u00e1 dokument vlastn\u00edka!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"Potomek atributu nem\u00e1 prvek dokumentu vlastn\u00edka!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Varov\u00e1n\u00ed: v\u00fdstup textu nem\u016f\u017ee p\u0159edch\u00e1zet prvku dokumentu! Ignorov\u00e1no..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"DOM nem\u016f\u017ee m\u00edt n\u011bkolik ko\u0159en\u016f!"},
{ ER_ARG_LOCALNAME_NULL,
"Argument 'localName' m\u00e1 hodnotu null"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Hodnota Localname ve funkci QNAME by m\u011bla b\u00fdt platn\u00fdm prvkem NCName"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"P\u0159edpona ve funkci QNAME by m\u011bla b\u00fdt platn\u00fdm prvkem NCName"},
{ "BAD_CODE", "Parametr funkce createMessage je mimo limit"},
{ "FORMAT_FAILED", "P\u0159i vol\u00e1n\u00ed funkce messageFormat do\u0161lo k v\u00fdjimce"},
{ "line", "\u0158\u00e1dek #"},
{ "column","Sloupec #"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"T\u0159\u00edda serializace ''{0}'' neimplementuje org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"Nelze naj\u00edt zdroj [ {0} ].\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"Nelze zav\u00e9st zdroj [ {0} ]: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Velikost vyrovn\u00e1vac\u00ed pam\u011bti <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Byla zji\u0161t\u011bna neplatn\u00e1 n\u00e1hrada UTF-16: {0} ?" },
{ER_OIERROR,
"Chyba vstupu/v\u00fdstupu" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Nelze p\u0159idat atribut {0} po uzlech potomk\u016f ani p\u0159ed t\u00edm, ne\u017e je vytvo\u0159en prvek. Atribut bude ignorov\u00e1n."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"Obor n\u00e1zv\u016f pro p\u0159edponu ''{0}'' nebyl deklarov\u00e1n." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Atribut ''{0}'' je vn\u011b prvku." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Deklarace oboru n\u00e1zv\u016f ''{0}''=''{1}'' je vn\u011b prvku." },
{ER_COULD_NOT_LOAD_RESOURCE,
"Nelze zav\u00e9st ''{0}'' (zkontrolujte prom\u011bnnou CLASSPATH), proto se pou\u017e\u00edvaj\u00ed pouze v\u00fdchoz\u00ed hodnoty"},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Nelze na\u010d\u00edst soubor vlastnost\u00ed ''{0}'' pro v\u00fdstupn\u00ed metodu ''{1}'' (zkontrolujte prom\u011bnnou CLASSPATH)." }
};
/**
* Get the lookup table for error messages
*
* @return The association list.
*/
public Object[][] getContents()
{
return _contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_de extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Funktion nicht unterst\u00FCtzt."},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Ursache kann nicht \u00FCberschrieben werden"},
{ ER_NO_DEFAULT_IMPL,
"Keine Standardimplementierung gefunden "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) derzeit nicht unterst\u00FCtzt"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Offset gr\u00F6\u00DFer als Slot"},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine nicht verf\u00FCgbar; ID={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager hat co_exit()-Anforderung erhalten"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() nicht erfolgreich"},
{ ER_COROUTINE_PARAM,
"Coroutine-Parameterfehler ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nUNEXPECTED: Parser doTerminate antwortet {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"\"parse\" darf w\u00E4hrend des Parsing nicht aufgerufen werden"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Fehler: Typisierter Iterator f\u00FCr Achse {0} nicht implementiert"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Fehler: Iterator f\u00FCr Achse {0} nicht implementiert "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Iteratorclone nicht unterst\u00FCtzt"},
{ ER_UNKNOWN_AXIS_TYPE,
"Unbekannter Achsendurchlauftyp: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Achsen-Traverser nicht unterst\u00FCtzt: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"Keine weiteren DTM-IDs verf\u00FCgbar"},
{ ER_NOT_SUPPORTED,
"Nicht unterst\u00FCtzt: {0}"},
{ ER_NODE_NON_NULL,
"Knoten darf nicht null sein f\u00FCr getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Knoten konnte nicht in Handle aufgel\u00F6st werden"},
{ ER_STARTPARSE_WHILE_PARSING,
"\"startParse\" darf w\u00E4hrend des Parsing nicht aufgerufen werden"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse erfordert einen SAXParser ungleich null"},
{ ER_COULD_NOT_INIT_PARSER,
"Parser konnte nicht initialisiert werden mit"},
{ ER_EXCEPTION_CREATING_POOL,
"Ausnahme beim Erstellen einer neuen Instanz f\u00FCr Pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Pfad enth\u00E4lt eine ung\u00FCltige Escapesequenz"},
{ ER_SCHEME_REQUIRED,
"Schema ist erforderlich."},
{ ER_NO_SCHEME_IN_URI,
"Kein Schema gefunden in URI: {0}"},
{ ER_NO_SCHEME_INURI,
"Kein Schema gefunden in URI"},
{ ER_PATH_INVALID_CHAR,
"Pfad enth\u00E4lt ung\u00FCltiges Zeichen: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Schema kann nicht von Nullzeichenfolge festgelegt werden"},
{ ER_SCHEME_NOT_CONFORMANT,
"Schema ist nicht konform."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Host ist keine wohlgeformte Adresse"},
{ ER_PORT_WHEN_HOST_NULL,
"Port kann nicht festgelegt werden, wenn der Host null ist"},
{ ER_INVALID_PORT,
"Ung\u00FCltige Portnummer"},
{ ER_FRAG_FOR_GENERIC_URI,
"Fragment kann nur f\u00FCr einen generischen URI festgelegt werden"},
{ ER_FRAG_WHEN_PATH_NULL,
"Fragment kann nicht festgelegt werden, wenn der Pfad null ist"},
{ ER_FRAG_INVALID_CHAR,
"Fragment enth\u00E4lt ein ung\u00FCltiges Zeichen"},
{ ER_PARSER_IN_USE,
"Parser wird bereits verwendet"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"{0} {1} kann w\u00E4hrend Parsing nicht ge\u00E4ndert werden"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Selbstkausalit\u00E4t nicht zul\u00E4ssig"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Benutzerinformationen k\u00F6nnen nicht angegeben werden, wenn der Host nicht angegeben wurde"},
{ ER_NO_PORT_IF_NO_HOST,
"Port kann nicht angegeben werden, wenn der Host nicht angegeben wurde"},
{ ER_NO_QUERY_STRING_IN_PATH,
"Abfragezeichenfolge kann nicht im Pfad und in der Abfragezeichenfolge angegeben werden"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Fragment kann nicht im Pfad und im Fragment angegeben werden"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"URI kann nicht mit leeren Parametern initialisiert werden"},
{ ER_METHOD_NOT_SUPPORTED,
"Methode noch nicht unterst\u00FCtzt "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter kann derzeit nicht neu gestartet werden"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader nicht vor startParse-Anforderung"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Achsen-Traverser nicht unterst\u00FCtzt: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler mit Null-PrintWriter erstellt."},
{ ER_SYSTEMID_UNKNOWN,
"SystemId unbekannt"},
{ ER_LOCATION_UNKNOWN,
"Fehlerposition unbekannt"},
{ ER_PREFIX_MUST_RESOLVE,
"Pr\u00E4fix muss in Namespace aufgel\u00F6st werden: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() nicht in XPathContext unterst\u00FCtzt."},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"Untergeordnetes Attribut hat kein Eigent\u00FCmerdokument."},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"Untergeordnetes Attribut hat kein Eigent\u00FCmerdokumentelement."},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Warnung: Text kann nicht vor Dokumentelement ausgegeben werden. Wird ignoriert..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"Mehrere Roots f\u00FCr ein DOM nicht zul\u00E4ssig."},
{ ER_ARG_LOCALNAME_NULL,
"Argument \"localName\" ist null"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Localname in QNAME muss ein g\u00FCltiger NCName sein"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"Pr\u00E4fix in QNAME muss ein g\u00FCltiger NCName sein"},
{ ER_NAME_CANT_START_WITH_COLON,
"Name darf nicht mit einem Doppelpunkt beginnen"},
{ "BAD_CODE", "Parameter f\u00FCr createMessage war au\u00DFerhalb des g\u00FCltigen Bereichs"},
{ "FORMAT_FAILED", "Ausnahme bei messageFormat-Aufruf ausgel\u00F6st"},
{ "line", "Zeilennummer"},
{ "column","Spaltennummer"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"Serializer-Klasse \"{0}\" implementiert org.xml.sax.ContentHandler nicht."},
{ER_RESOURCE_COULD_NOT_FIND,
"Ressource [ {0} ] konnte nicht gefunden werden.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"Ressource [ {0} ] konnte nicht geladen werden: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Puffergr\u00F6\u00DFe <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Ung\u00FCltige UTF-16-Ersetzung festgestellt: {0}?" },
{ER_OIERROR,
"I/O-Fehler" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Attribut {0} kann nicht nach untergeordneten Knoten oder vor dem Erstellen eines Elements hinzugef\u00FCgt werden. Attribut wird ignoriert."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"Namespace f\u00FCr Pr\u00E4fix \"{0}\" wurde nicht deklariert." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Attribut \"{0}\" au\u00DFerhalb des Elements." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Namespace-Deklaration {0}={1} au\u00DFerhalb des Elements." },
{ER_COULD_NOT_LOAD_RESOURCE,
"\"{0}\" konnte nicht geladen werden (CLASSPATH pr\u00FCfen). Die Standardwerte werden verwendet"},
{ ER_ILLEGAL_CHARACTER,
"Versuch, Zeichen mit Integralwert {0} auszugeben, das nicht in der speziellen Ausgabecodierung von {1} dargestellt wird."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Property-Datei \"{0}\" konnte f\u00FCr Ausgabemethode \"{1}\" nicht geladen werden (CLASSPATH pr\u00FCfen)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,32 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
/**
* Default implementation of XPATHErrorResources. This is just
* an empty class.
* @xsl.usage advanced
*/
public class XMLErrorResources_en extends XMLErrorResources
{
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_es extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Funci\u00F3n no soportada."},
{ ER_CANNOT_OVERWRITE_CAUSE,
"No se puede sobrescribir la causa"},
{ ER_NO_DEFAULT_IMPL,
"No se ha encontrado la implantaci\u00F3n por defecto "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) no est\u00E1 soportado actualmente"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"El desplazamiento es mayor que la ranura"},
{ ER_COROUTINE_NOT_AVAIL,
"Corrutina no disponible, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager ha recibido la solicitud co_exit()"},
{ ER_COJOINROUTINESET_FAILED,
"Fallo de co_joinCoroutineSet()"},
{ ER_COROUTINE_PARAM,
"Error de par\u00E1metro de corrutina ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nINESPERADO: respuestas doTerminate del analizador {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"no se puede realizar un an\u00E1lisis mientras se lleva a cabo otro"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Error: el iterador introducido para el eje {0} no se ha implantado"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Error: el iterador para el eje {0} no se ha implantado "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"La clonaci\u00F3n del iterador no est\u00E1 soportada"},
{ ER_UNKNOWN_AXIS_TYPE,
"Tipo de recorrido de eje desconocido: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Traverser de eje no soportado: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"No hay m\u00E1s identificadores de DTM disponibles"},
{ ER_NOT_SUPPORTED,
"No soportado: {0}"},
{ ER_NODE_NON_NULL,
"El nodo debe ser no nulo para getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"No se ha podido resolver el nodo en un identificador"},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse no puede llamarse durante el an\u00E1lisis"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse necesita un SAXParser no nulo"},
{ ER_COULD_NOT_INIT_PARSER,
"no se ha podido inicializar el analizador con"},
{ ER_EXCEPTION_CREATING_POOL,
"excepci\u00F3n al crear la nueva instancia para el pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"La ruta de acceso contiene una secuencia de escape no v\u00E1lida"},
{ ER_SCHEME_REQUIRED,
"Se necesita un esquema."},
{ ER_NO_SCHEME_IN_URI,
"No se ha encontrado un esquema en el URI: {0}"},
{ ER_NO_SCHEME_INURI,
"No se ha encontrado un esquema en el URI"},
{ ER_PATH_INVALID_CHAR,
"La ruta de acceso contiene un car\u00E1cter no v\u00E1lido: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"No se puede definir un esquema a partir de una cadena nula"},
{ ER_SCHEME_NOT_CONFORMANT,
"El esquema no es v\u00E1lido."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"El formato de la direcci\u00F3n de host no es correcto"},
{ ER_PORT_WHEN_HOST_NULL,
"No se puede definir el puerto si el host es nulo"},
{ ER_INVALID_PORT,
"N\u00FAmero de puerto no v\u00E1lido"},
{ ER_FRAG_FOR_GENERIC_URI,
"S\u00F3lo se puede definir el fragmento para un URI gen\u00E9rico"},
{ ER_FRAG_WHEN_PATH_NULL,
"No se puede definir el fragmento si la ruta de acceso es nula"},
{ ER_FRAG_INVALID_CHAR,
"El fragmento contiene un car\u00E1cter no v\u00E1lido"},
{ ER_PARSER_IN_USE,
"El analizador ya se est\u00E1 utilizando"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"No se puede cambiar {0} {1} durante el an\u00E1lisis"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"La autocausalidad no est\u00E1 permitida"},
{ ER_NO_USERINFO_IF_NO_HOST,
"No se puede especificar la informaci\u00F3n de usuario si no se ha especificado el host"},
{ ER_NO_PORT_IF_NO_HOST,
"No se puede especificar el puerto si no se ha especificado el host"},
{ ER_NO_QUERY_STRING_IN_PATH,
"No se puede especificar la cadena de consulta en la ruta de acceso y en la cadena de consulta"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"No se puede especificar el fragmento en la ruta de acceso y en el fragmento"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"No se puede inicializar el URI con par\u00E1metros vac\u00EDos"},
{ ER_METHOD_NOT_SUPPORTED,
"M\u00E9todo no soportado a\u00FAn "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter no se puede reiniciar actualmente"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader no anterior a la solicitud startParse"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Traverser de eje no soportado: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler se ha creado con un valor de PrintWriter nulo"},
{ ER_SYSTEMID_UNKNOWN,
"Identificador de Sistema Desconocido"},
{ ER_LOCATION_UNKNOWN,
"Ubicaci\u00F3n del error desconocida"},
{ ER_PREFIX_MUST_RESOLVE,
"El prefijo se debe resolver en un espacio de nombres: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() no soportado en XPathContext"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"El atributo child no tiene un documento de propietario."},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"El atributo child no tiene un elemento de documento de propietario."},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Advertencia: no se puede realizar la salida de texto antes del elemento del documento. Ignorando..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"No se puede tener m\u00E1s de una ra\u00EDz en un DOM."},
{ ER_ARG_LOCALNAME_NULL,
"El argumento 'localName' es nulo"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"El nombre local de QNAME debe ser un NCName v\u00E1lido"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"El prefijo de QNAME debe ser un NCName v\u00E1lido"},
{ ER_NAME_CANT_START_WITH_COLON,
"El nombre no puede empezar con dos puntos"},
{ "BAD_CODE", "El par\u00E1metro para crear un mensaje est\u00E1 fuera de los l\u00EDmites"},
{ "FORMAT_FAILED", "Se ha emitido una excepci\u00F3n durante la llamada a messageFormat"},
{ "line", "N\u00BA de L\u00EDnea"},
{ "column","N\u00BA de Columna"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"La clase de serializador ''{0}'' no implanta org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"No se ha encontrado el recurso [ {0} ].\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"No se ha podido cargar el recurso [ {0} ]: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Tama\u00F1o de buffer menor o igual que 0" },
{ER_INVALID_UTF16_SURROGATE,
"\u00BFSe ha detectado un sustituto UTF-16 no v\u00E1lido: {0}?" },
{ER_OIERROR,
"Error de ES" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"No se puede agregar el atributo {0} despu\u00E9s de nodos secundarios o antes de que se produzca un elemento. Se ignorar\u00E1 el atributo."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"No se ha declarado el espacio de nombres para el prefijo ''{0}''." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"El atributo ''{0}'' est\u00E1 fuera del elemento." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Declaraci\u00F3n del espacio de nombres ''{0}''=''{1}'' fuera del elemento." },
{ER_COULD_NOT_LOAD_RESOURCE,
"No se ha podido cargar ''{0}'' (compruebe la CLASSPATH), ahora s\u00F3lo se est\u00E1n utilizando los valores por defecto"},
{ ER_ILLEGAL_CHARACTER,
"Intento de realizar la salida del car\u00E1cter del valor integral {0}, que no est\u00E1 representado en la codificaci\u00F3n de salida de {1}."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"No se ha podido cargar el archivo de propiedades ''{0}'' para el m\u00E9todo de salida ''{1}'' (compruebe la CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_fr extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Fonction non prise en charge."},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Impossible de remplacer la cause"},
{ ER_NO_DEFAULT_IMPL,
"Aucune impl\u00E9mentation par d\u00E9faut trouv\u00E9e "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) n''est actuellement pas pris en charge"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"D\u00E9calage sup\u00E9rieur \u00E0 l'emplacement"},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine non disponible, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager a re\u00E7u la demande co_exit()"},
{ ER_COJOINROUTINESET_FAILED,
"Echec de co_joinCoroutineSet()"},
{ ER_COROUTINE_PARAM,
"Erreur de param\u00E8tre de coroutine ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nINATTENDU : r\u00E9ponses doTerminate de l''analyseur - {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"impossible d'appeler l'analyse lorsqu'elle est en cours"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Erreur : it\u00E9rateur saisi pour l''axe {0} non impl\u00E9ment\u00E9"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Erreur : it\u00E9rateur pour l''axe {0} non impl\u00E9ment\u00E9 "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Clone d'it\u00E9rateur non pris en charge"},
{ ER_UNKNOWN_AXIS_TYPE,
"Type de parcours d''axe inconnu : {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Parcours d''axe non pris en charge : {0}"},
{ ER_NO_DTMIDS_AVAIL,
"Aucun autre ID DTM n'est disponible"},
{ ER_NOT_SUPPORTED,
"Non pris en charge : {0}"},
{ ER_NODE_NON_NULL,
"Le noeud doit \u00EAtre non NULL pour getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Impossible de r\u00E9soudre le noeud sur un descripteur"},
{ ER_STARTPARSE_WHILE_PARSING,
"impossible d'appeler startParse lorsque l'analyse est en cours"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse n\u00E9cessite un SAXParser non NULL"},
{ ER_COULD_NOT_INIT_PARSER,
"impossible d'initialiser l'analyseur avec"},
{ ER_EXCEPTION_CREATING_POOL,
"exception lors de la cr\u00E9ation de l'instance du pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Le chemin d'acc\u00E8s contient une s\u00E9quence d'\u00E9chappement non valide"},
{ ER_SCHEME_REQUIRED,
"Mod\u00E8le obligatoire."},
{ ER_NO_SCHEME_IN_URI,
"Mod\u00E8le introuvable dans l''URI: {0}"},
{ ER_NO_SCHEME_INURI,
"Mod\u00E8le introuvable dans l'URI"},
{ ER_PATH_INVALID_CHAR,
"Le chemin contient un caract\u00E8re non valide : {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Impossible de d\u00E9finir le mod\u00E8le \u00E0 partir de la cha\u00EEne NULL"},
{ ER_SCHEME_NOT_CONFORMANT,
"Le mod\u00E8le n'est pas conforme."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Le format de l'adresse de l'h\u00F4te n'est pas correct"},
{ ER_PORT_WHEN_HOST_NULL,
"Impossible de d\u00E9finir le port quand l'h\u00F4te est NULL"},
{ ER_INVALID_PORT,
"Num\u00E9ro de port non valide"},
{ ER_FRAG_FOR_GENERIC_URI,
"Le fragment ne peut \u00EAtre d\u00E9fini que pour un URI g\u00E9n\u00E9rique"},
{ ER_FRAG_WHEN_PATH_NULL,
"Impossible de d\u00E9finir le fragment quand le chemin d'acc\u00E8s est NULL"},
{ ER_FRAG_INVALID_CHAR,
"Le fragment contient un caract\u00E8re non valide"},
{ ER_PARSER_IN_USE,
"L'analyseur est d\u00E9j\u00E0 utilis\u00E9"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"Impossible de modifier {0} {1} pendant l''analyse"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Causalit\u00E9 circulaire non autoris\u00E9e"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Userinfo peut ne pas \u00EAtre sp\u00E9cifi\u00E9 si l'h\u00F4te ne l'est pas"},
{ ER_NO_PORT_IF_NO_HOST,
"Le port peut ne pas \u00EAtre sp\u00E9cifi\u00E9 si l'h\u00F4te ne l'est pas"},
{ ER_NO_QUERY_STRING_IN_PATH,
"La cha\u00EEne de requ\u00EAte ne doit pas figurer dans un chemin et une cha\u00EEne de requ\u00EAte"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Le fragment ne doit pas \u00EAtre indiqu\u00E9 \u00E0 la fois dans le chemin et dans le fragment"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"Impossible d'initialiser l'URI avec des param\u00E8tres vides"},
{ ER_METHOD_NOT_SUPPORTED,
"La m\u00E9thode n'est pas encore prise en charge "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter ne peut actuellement pas \u00EAtre red\u00E9marr\u00E9"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader pas avant la demande startParse"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Parcours d''axe non pris en charge : {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler cr\u00E9\u00E9 avec PrintWriter NULL."},
{ ER_SYSTEMID_UNKNOWN,
"ID syst\u00E8me inconnu"},
{ ER_LOCATION_UNKNOWN,
"Emplacement de l'erreur inconnu"},
{ ER_PREFIX_MUST_RESOLVE,
"Le pr\u00E9fixe doit \u00EAtre r\u00E9solu en espace de noms : {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() non pris en charge dans XPathContext."},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"L'enfant de l'attribut ne poss\u00E8de pas de document propri\u00E9taire."},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"L'enfant de l'attribut ne poss\u00E8de pas d'\u00E9l\u00E9ment de document propri\u00E9taire."},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Avertissement : impossible de g\u00E9n\u00E9rer une sortie du texte avant l'\u00E9l\u00E9ment de document. Non pris en compte..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"Impossible d'avoir plus d'une racine sur un DOM."},
{ ER_ARG_LOCALNAME_NULL,
"L'argument \"localName\" est NULL"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Le nom local du QName doit \u00EAtre un NCName valide"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"Le pr\u00E9fixe du QName doit \u00EAtre un NCName valide"},
{ ER_NAME_CANT_START_WITH_COLON,
"Le nom ne peut pas commencer par deux-points"},
{ "BAD_CODE", "Le param\u00E8tre createMessage \u00E9tait hors limites"},
{ "FORMAT_FAILED", "Exception g\u00E9n\u00E9r\u00E9e pendant l'appel messageFormat"},
{ "line", "Ligne n\u00B0"},
{ "column","Colonne n\u00B0"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"La classe de serializer ''{0}'' n''impl\u00E9mente pas org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"La ressource [ {0} ] est introuvable.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"La ressource [ {0} ] n''a pas pu charger : {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Taille du tampon <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Substitut UTF-16 non valide d\u00E9tect\u00E9 : {0} ?" },
{ER_OIERROR,
"Erreur d'E-S" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Impossible d''ajouter l''attribut {0} apr\u00E8s des noeuds enfant ou avant la production d''un \u00E9l\u00E9ment. L''attribut est ignor\u00E9."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"L''espace de noms du pr\u00E9fixe ''{0}'' n''a pas \u00E9t\u00E9 d\u00E9clar\u00E9." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Attribut ''{0}'' \u00E0 l''ext\u00E9rieur de l''\u00E9l\u00E9ment." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"La d\u00E9claration d''espace de noms ''{0}''=''{1}'' est \u00E0 l''ext\u00E9rieur de l''\u00E9l\u00E9ment." },
{ER_COULD_NOT_LOAD_RESOURCE,
"Impossible de charger ''{0}'' (v\u00E9rifier CLASSPATH), les valeurs par d\u00E9faut sont donc employ\u00E9es"},
{ ER_ILLEGAL_CHARACTER,
"Tentative de sortie d''un caract\u00E8re avec une valeur enti\u00E8re {0}, non repr\u00E9sent\u00E9 dans l''encodage de sortie sp\u00E9cifi\u00E9 pour {1}."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Impossible de charger le fichier de propri\u00E9t\u00E9s ''{0}'' pour la m\u00E9thode de sortie ''{1}'' (v\u00E9rifier CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_it extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Funzione non supportata."},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Impossibile sovrascrivere la causa"},
{ ER_NO_DEFAULT_IMPL,
"Nessuna implementazione predefinita trovata "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) non supportato al momento"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Offset pi\u00F9 grande dello slot"},
{ ER_COROUTINE_NOT_AVAIL,
"Co-routine non disponibile, ID={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager ha ricevuto una richiesta co_exit()"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() non riuscito"},
{ ER_COROUTINE_PARAM,
"Errore del parametro di co-routine ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nIMPREVISTO: risposte doTerminate del parser {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"impossibile richiamare parse mentre \u00E8 in corso un'analisi"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Errore: l''iteratore con tipo per l''asse {0} non \u00E8 implementato"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Errore: l''iteratore per l''asse {0} non \u00E8 implementato "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Duplicazione dell'iteratore non supportata"},
{ ER_UNKNOWN_AXIS_TYPE,
"Tipo di asse trasversale sconosciuto: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Asse trasversale non supportato: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"Non sono disponibili altri ID DTM"},
{ ER_NOT_SUPPORTED,
"Non supportato: {0}"},
{ ER_NODE_NON_NULL,
"Il nodo deve essere non nullo per getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Impossibile risolvere il nodo in un handle"},
{ ER_STARTPARSE_WHILE_PARSING,
"impossibile richiamare startParse mentre \u00E8 in corso un'analisi"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse richiede un valore non nullo per SAXParser"},
{ ER_COULD_NOT_INIT_PARSER,
"impossibile inizializzare il parser con"},
{ ER_EXCEPTION_CREATING_POOL,
"eccezione durante la creazione di una nuova istanza per il pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Il percorso contiene sequenza di escape non valida"},
{ ER_SCHEME_REQUIRED,
"Lo schema \u00E8 obbligatorio."},
{ ER_NO_SCHEME_IN_URI,
"Nessuno schema trovato nell''URI: {0}"},
{ ER_NO_SCHEME_INURI,
"Nessuno schema trovato nell'URI"},
{ ER_PATH_INVALID_CHAR,
"Il percorso contiene un carattere non valido: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Impossibile impostare lo schema da una stringa nulla"},
{ ER_SCHEME_NOT_CONFORMANT,
"Lo schema non \u00E8 conforme."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Host non \u00E8 un indirizzo corretto"},
{ ER_PORT_WHEN_HOST_NULL,
"La porta non pu\u00F2 essere impostata se l'host \u00E8 nullo"},
{ ER_INVALID_PORT,
"Numero di porta non valido"},
{ ER_FRAG_FOR_GENERIC_URI,
"Il frammento pu\u00F2 essere impostato solo per un URI generico"},
{ ER_FRAG_WHEN_PATH_NULL,
"Il frammento non pu\u00F2 essere impostato se il percorso \u00E8 nullo"},
{ ER_FRAG_INVALID_CHAR,
"Il frammento contiene un carattere non valido"},
{ ER_PARSER_IN_USE,
"Parser gi\u00E0 in uso"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"Impossibile modificare {0} {1} durante l''analisi"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Creazione automatica della causa non consentita"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Userinfo non pu\u00F2 essere specificato se l'host non \u00E8 specificato"},
{ ER_NO_PORT_IF_NO_HOST,
"La porta non pu\u00F2 essere specificata se l'host non \u00E8 specificato"},
{ ER_NO_QUERY_STRING_IN_PATH,
"La stringa di query non pu\u00F2 essere specificata nella stringa di percorso e query."},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Il frammento non pu\u00F2 essere specificato sia nel percorso che nel frammento"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"Impossibile inizializzare l'URI con i parametri vuoti"},
{ ER_METHOD_NOT_SUPPORTED,
"Metodo attualmente non supportato "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter attualmente non riavviabile"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader non si trova prima della richiesta startParse"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Asse trasversale non supportato: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler creato con PrintWriter nullo."},
{ ER_SYSTEMID_UNKNOWN,
"SystemId sconosciuto"},
{ ER_LOCATION_UNKNOWN,
"Posizione sconosciuta dell'errore"},
{ ER_PREFIX_MUST_RESOLVE,
"Il prefisso deve essere risolto in uno spazio di nomi: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() non supportato in XPathContext"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"L'elemento figlio dell'attributo non dispone di un documento proprietario."},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"L'elemento figlio dell'attributo non dispone di un elemento di documento proprietario."},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Avvertenza: impossibile creare l'output del testo prima dell'elemento del documento. Operazione ignorata..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"Non possono esistere pi\u00F9 radici in un DOM."},
{ ER_ARG_LOCALNAME_NULL,
"L'argomento 'localName' \u00E8 nullo"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Localname in QNAME deve essere un NCName valido"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"Il prefisso in QNAME deve essere un NCName valido"},
{ ER_NAME_CANT_START_WITH_COLON,
"Il nome non pu\u00F2 iniziare con i due punti"},
{ "BAD_CODE", "Parametro per createMessage fuori limite"},
{ "FORMAT_FAILED", "Eccezione durante la chiamata messageFormat"},
{ "line", "N. riga"},
{ "column","N. colonna"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"La classe serializzatore ''{0}'' non implementa org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"Risorsa [ {0} ] non trovata.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"Impossibile caricare la risorsa [ {0} ]: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Dimensione buffer <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Rilevato surrogato UTF-16 non valido: {0}?" },
{ER_OIERROR,
"Errore IO" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Impossibile aggiungere l''attributo {0} dopo i nodi figlio o prima che sia prodotto un elemento. L''attributo verr\u00E0 ignorato."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"Lo spazio di nomi per il prefisso ''{0}'' non \u00E8 stato dichiarato." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Attributo ''{0}'' al di fuori dell''elemento." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Dichiarazione dello spazio di nomi ''{0}''=''{1}'' al di fuori dell''elemento." },
{ER_COULD_NOT_LOAD_RESOURCE,
"Impossibile caricare ''{0}'' (verificare CLASSPATH); verranno utilizzati i valori predefiniti"},
{ ER_ILLEGAL_CHARACTER,
"Tentativo di eseguire l''output di un carattere di valore integrale {0} non rappresentato nella codifica di output {1} specificata."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Impossibile caricare il file delle propriet\u00E0 ''{0}'' per il metodo di emissione ''{1}'' (verificare CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_ja extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"\u95A2\u6570\u304C\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"\u539F\u56E0\u3092\u4E0A\u66F8\u304D\u3067\u304D\u307E\u305B\u3093"},
{ ER_NO_DEFAULT_IMPL,
"\u30C7\u30D5\u30A9\u30EB\u30C8\u5B9F\u88C5\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0})\u306F\u73FE\u5728\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"\u30AA\u30D5\u30BB\u30C3\u30C8\u304C\u30B9\u30ED\u30C3\u30C8\u3088\u308A\u3082\u5927\u304D\u3044\u3067\u3059"},
{ ER_COROUTINE_NOT_AVAIL,
"\u30B3\u30EB\u30FC\u30C1\u30F3\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager\u304Cco_exit()\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u53D7\u3051\u53D6\u308A\u307E\u3057\u305F"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet()\u304C\u5931\u6557\u3057\u307E\u3057\u305F"},
{ ER_COROUTINE_PARAM,
"\u30B3\u30EB\u30FC\u30C1\u30F3\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u30A8\u30E9\u30FC({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\n\u4E0D\u660E: \u30D1\u30FC\u30B5\u30FCdoTerminate\u306E\u5FDC\u7B54\u306F{0}\u3067\u3059"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"\u89E3\u6790\u306F\u69CB\u6587\u89E3\u6790\u4E2D\u306B\u547C\u3073\u51FA\u3059\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\u30A8\u30E9\u30FC: \u8EF8{0}\u306E\u578B\u6307\u5B9A\u3055\u308C\u305F\u30A4\u30C6\u30EC\u30FC\u30BF\u304C\u5B9F\u88C5\u3055\u308C\u3066\u3044\u307E\u305B\u3093"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\u30A8\u30E9\u30FC: \u8EF8{0}\u306E\u30A4\u30C6\u30EC\u30FC\u30BF\u304C\u5B9F\u88C5\u3055\u308C\u3066\u3044\u307E\u305B\u3093 "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"\u30A4\u30C6\u30EC\u30FC\u30BF\u306E\u30AF\u30ED\u30FC\u30F3\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093"},
{ ER_UNKNOWN_AXIS_TYPE,
"\u4E0D\u660E\u306A\u8EF8\u30C8\u30E9\u30D0\u30FC\u30B9\u30FB\u30BF\u30A4\u30D7\u3067\u3059: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"\u8EF8\u30C8\u30E9\u30D0\u30FC\u30B5\u6A5F\u80FD\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"DTM ID\u306F\u3053\u308C\u4EE5\u4E0A\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093"},
{ ER_NOT_SUPPORTED,
"\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}"},
{ ER_NODE_NON_NULL,
"\u30CE\u30FC\u30C9\u306FgetDTMHandleFromNode\u306B\u3064\u3044\u3066\u975Enull\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"},
{ ER_COULD_NOT_RESOLVE_NODE,
"\u30CE\u30FC\u30C9\u3092\u30CF\u30F3\u30C9\u30EB\u306B\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F"},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse\u306F\u69CB\u6587\u89E3\u6790\u4E2D\u306B\u547C\u3073\u51FA\u3059\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse\u306B\u306F\u975Enull\u306ESAXParser\u304C\u5FC5\u8981\u3067\u3059"},
{ ER_COULD_NOT_INIT_PARSER,
"\u6B21\u306E\u7406\u7531\u3067\u30D1\u30FC\u30B5\u30FC\u3092\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: "},
{ ER_EXCEPTION_CREATING_POOL,
"\u30D7\u30FC\u30EB\u7528\u306E\u65B0\u898F\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306E\u4F5C\u6210\u4E2D\u306B\u767A\u751F\u3057\u305F\u4F8B\u5916"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"\u30D1\u30B9\u306B\u7121\u52B9\u306A\u30A8\u30B9\u30B1\u30FC\u30D7\u30FB\u30B7\u30FC\u30B1\u30F3\u30B9\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059"},
{ ER_SCHEME_REQUIRED,
"\u30B9\u30AD\u30FC\u30E0\u304C\u5FC5\u8981\u3067\u3059\u3002"},
{ ER_NO_SCHEME_IN_URI,
"\u30B9\u30AD\u30FC\u30E0\u304CURI\u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}"},
{ ER_NO_SCHEME_INURI,
"\u30B9\u30AD\u30FC\u30E0\u304CURI\u306B\u898B\u3064\u304B\u308A\u307E\u305B\u3093"},
{ ER_PATH_INVALID_CHAR,
"\u30D1\u30B9\u306B\u7121\u52B9\u306A\u6587\u5B57\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"null\u6587\u5B57\u5217\u304B\u3089\u306F\u30B9\u30AD\u30FC\u30E0\u3092\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_SCHEME_NOT_CONFORMANT,
"\u30B9\u30AD\u30FC\u30E0\u304C\u6574\u5408\u3057\u3066\u3044\u307E\u305B\u3093\u3002"},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"\u30DB\u30B9\u30C8\u306F\u6574\u5F62\u5F0F\u306E\u30A2\u30C9\u30EC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093"},
{ ER_PORT_WHEN_HOST_NULL,
"\u30DB\u30B9\u30C8\u304Cnull\u306E\u5834\u5408\u306F\u30DD\u30FC\u30C8\u3092\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_INVALID_PORT,
"\u7121\u52B9\u306A\u30DD\u30FC\u30C8\u756A\u53F7"},
{ ER_FRAG_FOR_GENERIC_URI,
"\u6C4E\u7528URI\u306E\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u306E\u307F\u8A2D\u5B9A\u3067\u304D\u307E\u3059"},
{ ER_FRAG_WHEN_PATH_NULL,
"\u30D1\u30B9\u304Cnull\u306E\u5834\u5408\u306F\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u3092\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_FRAG_INVALID_CHAR,
"\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u306B\u7121\u52B9\u6587\u5B57\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059"},
{ ER_PARSER_IN_USE,
"\u30D1\u30FC\u30B5\u30FC\u306F\u3059\u3067\u306B\u4F7F\u7528\u4E2D\u3067\u3059"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"\u89E3\u6790\u4E2D\u306B{0} {1}\u3092\u5909\u66F4\u3067\u304D\u307E\u305B\u3093"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"\u81EA\u5DF1\u539F\u56E0\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093"},
{ ER_NO_USERINFO_IF_NO_HOST,
"\u30DB\u30B9\u30C8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u306FUserinfo\u3092\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_NO_PORT_IF_NO_HOST,
"\u30DB\u30B9\u30C8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u306F\u30DD\u30FC\u30C8\u3092\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_NO_QUERY_STRING_IN_PATH,
"\u554F\u5408\u305B\u6587\u5B57\u5217\u306F\u30D1\u30B9\u304A\u3088\u3073\u554F\u5408\u305B\u6587\u5B57\u5217\u5185\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u306F\u30D1\u30B9\u3068\u30D5\u30E9\u30B0\u30E1\u30F3\u30C8\u306E\u4E21\u65B9\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"URI\u306F\u7A7A\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u3066\u521D\u671F\u5316\u3067\u304D\u307E\u305B\u3093"},
{ ER_METHOD_NOT_SUPPORTED,
"\u30E1\u30BD\u30C3\u30C9\u306F\u307E\u3060\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093 "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter\u306F\u73FE\u5728\u306F\u518D\u8D77\u52D5\u53EF\u80FD\u3067\u306F\u3042\u308A\u307E\u305B\u3093"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader\u306FstartParse\u30EA\u30AF\u30A8\u30B9\u30C8\u3088\u308A\u524D\u306B\u3067\u304D\u307E\u305B\u3093"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"\u8EF8\u30C8\u30E9\u30D0\u30FC\u30B5\u6A5F\u80FD\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"null PrintWriter\u306B\u3088\u3063\u3066ListingErrorHandler\u304C\u4F5C\u6210\u3055\u308C\u307E\u3057\u305F\u3002"},
{ ER_SYSTEMID_UNKNOWN,
"\u4E0D\u660E\u306ASystemId"},
{ ER_LOCATION_UNKNOWN,
"\u30A8\u30E9\u30FC\u306E\u5834\u6240\u304C\u4E0D\u660E\u3067\u3059"},
{ ER_PREFIX_MUST_RESOLVE,
"\u63A5\u982D\u8F9E\u306F\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u306B\u89E3\u6C7A\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument()\u306FXPathContext\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"\u5C5E\u6027\u306E\u5B50\u306B\u6240\u6709\u8005\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u304C\u3042\u308A\u307E\u305B\u3093\u3002"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"\u5C5E\u6027\u306E\u5B50\u306B\u6240\u6709\u8005\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u8981\u7D20\u304C\u3042\u308A\u307E\u305B\u3093\u3002"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"\u8B66\u544A: \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u8981\u7D20\u306E\u524D\u306B\u30C6\u30AD\u30B9\u30C8\u3092\u51FA\u529B\u3067\u304D\u307E\u305B\u3093\u3002 \u7121\u8996\u3057\u307E\u3059..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"DOM\u306B\u8907\u6570\u306E\u30EB\u30FC\u30C8\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002"},
{ ER_ARG_LOCALNAME_NULL,
"\u5F15\u6570'localName'\u306Fnull\u3067\u3059"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"QNAME\u306ELocalname\u306F\u6709\u52B9\u306ANCName\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"QNAME\u306E\u63A5\u982D\u8F9E\u306F\u6709\u52B9\u306ANCName\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"},
{ ER_NAME_CANT_START_WITH_COLON,
"\u540D\u524D\u306E\u5148\u982D\u3092\u30B3\u30ED\u30F3\u306B\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093"},
{ "BAD_CODE", "createMessage\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u7BC4\u56F2\u5916\u3067\u3059"},
{ "FORMAT_FAILED", "messageFormat\u306E\u547C\u51FA\u3057\u4E2D\u306B\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F"},
{ "line", "\u884C\u756A\u53F7"},
{ "column","\u5217\u756A\u53F7"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"\u30B7\u30EA\u30A2\u30E9\u30A4\u30B6\u30FB\u30AF\u30E9\u30B9''{0}''\u306Forg.xml.sax.ContentHandler\u3092\u5B9F\u88C5\u3057\u307E\u305B\u3093\u3002"},
{ER_RESOURCE_COULD_NOT_FIND,
"\u30EA\u30BD\u30FC\u30B9[ {0} ]\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"\u30EA\u30BD\u30FC\u30B9[ {0} ]\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"\u30D0\u30C3\u30D5\u30A1\u30FB\u30B5\u30A4\u30BA<=0" },
{ER_INVALID_UTF16_SURROGATE,
"\u7121\u52B9\u306AUTF-16\u30B5\u30ED\u30B2\u30FC\u30C8\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F: {0}\u3002" },
{ER_OIERROR,
"IO\u30A8\u30E9\u30FC" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"\u5B50\u30CE\u30FC\u30C9\u306E\u5F8C\u307E\u305F\u306F\u8981\u7D20\u304C\u751F\u6210\u3055\u308C\u308B\u524D\u306B\u5C5E\u6027{0}\u3092\u8FFD\u52A0\u3067\u304D\u307E\u305B\u3093\u3002\u5C5E\u6027\u306F\u7121\u8996\u3055\u308C\u307E\u3059\u3002"},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"\u63A5\u982D\u8F9E''{0}''\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u304C\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002" },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"\u5C5E\u6027''{0}''\u304C\u8981\u7D20\u306E\u5916\u5074\u306B\u3042\u308A\u307E\u3059\u3002" },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9\u5BA3\u8A00''{0}''=''{1}''\u304C\u8981\u7D20\u306E\u5916\u5074\u306B\u3042\u308A\u307E\u3059\u3002" },
{ER_COULD_NOT_LOAD_RESOURCE,
"''{0}''\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F(CLASSPATH\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044)\u3002\u73FE\u5728\u306F\u5358\u306B\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059"},
{ ER_ILLEGAL_CHARACTER,
"{1}\u306E\u6307\u5B9A\u3055\u308C\u305F\u51FA\u529B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3067\u793A\u3055\u308C\u306A\u3044\u6574\u6570\u5024{0}\u306E\u6587\u5B57\u3092\u51FA\u529B\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F\u3002"},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"\u51FA\u529B\u30E1\u30BD\u30C3\u30C9''{1}''\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F(CLASSPATH\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_ko extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"\uD568\uC218\uAC00 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"\uC6D0\uC778\uC744 \uACB9\uCCD0 \uC4F8 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_NO_DEFAULT_IMPL,
"\uAE30\uBCF8 \uAD6C\uD604\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0})\uB294 \uD604\uC7AC \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"\uC624\uD504\uC14B\uC774 \uC2AC\uB86F\uBCF4\uB2E4 \uD07D\uB2C8\uB2E4."},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine\uC744 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. ID={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager\uAC00 co_exit() \uC694\uCCAD\uC744 \uC218\uC2E0\uD588\uC2B5\uB2C8\uB2E4."},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet()\uB97C \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4."},
{ ER_COROUTINE_PARAM,
"Coroutine \uB9E4\uAC1C\uBCC0\uC218 \uC624\uB958({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\n\uC608\uC0C1\uCE58 \uC54A\uC740 \uC624\uB958: \uAD6C\uBB38 \uBD84\uC11D\uAE30 doTerminate\uAC00 {0}\uC5D0 \uC751\uB2F5\uD569\uB2C8\uB2E4."},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"\uAD6C\uBB38 \uBD84\uC11D \uC911 parse\uB97C \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\uC624\uB958: {0} \uCD95\uC5D0 \uB300\uD574 \uC785\uB825\uB41C \uC774\uD130\uB808\uC774\uD130\uAC00 \uAD6C\uD604\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\uC624\uB958: {0} \uCD95\uC5D0 \uB300\uD55C \uC774\uD130\uB808\uC774\uD130\uAC00 \uAD6C\uD604\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4. "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"\uC774\uD130\uB808\uC774\uD130 \uBCF5\uC81C\uB294 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."},
{ ER_UNKNOWN_AXIS_TYPE,
"\uC54C \uC218 \uC5C6\uB294 \uCD95 \uC21C\uD68C \uC720\uD615: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"\uCD95 \uC21C\uD658\uAE30\uAC00 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"\uB354 \uC774\uC0C1 \uC0AC\uC6A9 \uAC00\uB2A5\uD55C DTM ID\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_NOT_SUPPORTED,
"\uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"},
{ ER_NODE_NON_NULL,
"\uB178\uB4DC\uB294 getDTMHandleFromNode\uC5D0 \uB300\uD574 \uB110\uC774 \uC544\uB2C8\uC5B4\uC57C \uD569\uB2C8\uB2E4."},
{ ER_COULD_NOT_RESOLVE_NODE,
"\uB178\uB4DC\uB97C \uD578\uB4E4\uB85C \uBD84\uC11D\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_STARTPARSE_WHILE_PARSING,
"\uAD6C\uBB38 \uBD84\uC11D \uC911 startParse\uB97C \uD638\uCD9C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse\uC5D0\uB294 \uB110\uC774 \uC544\uB2CC SAXParser\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4."},
{ ER_COULD_NOT_INIT_PARSER,
"\uAD6C\uBB38 \uBD84\uC11D\uAE30\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_EXCEPTION_CREATING_POOL,
"\uD480\uC5D0 \uB300\uD55C \uC0C8 \uC778\uC2A4\uD134\uC2A4\uB97C \uC0DD\uC131\uD558\uB294 \uC911 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"\uACBD\uB85C\uC5D0 \uBD80\uC801\uD569\uD55C \uC774\uC2A4\uCF00\uC774\uD504 \uC2DC\uD000\uC2A4\uAC00 \uD3EC\uD568\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4."},
{ ER_SCHEME_REQUIRED,
"\uCCB4\uACC4\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4!"},
{ ER_NO_SCHEME_IN_URI,
"URI\uC5D0\uC11C \uCCB4\uACC4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC74C: {0}"},
{ ER_NO_SCHEME_INURI,
"URI\uC5D0\uC11C \uCCB4\uACC4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_PATH_INVALID_CHAR,
"\uACBD\uB85C\uC5D0 \uBD80\uC801\uD569\uD55C \uBB38\uC790\uAC00 \uD3EC\uD568\uB428: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"\uB110 \uBB38\uC790\uC5F4\uC5D0\uC11C \uCCB4\uACC4\uB97C \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_SCHEME_NOT_CONFORMANT,
"\uCCB4\uACC4\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"\uD638\uC2A4\uD2B8\uAC00 \uC644\uC804\uD55C \uC8FC\uC18C\uAC00 \uC544\uB2D9\uB2C8\uB2E4."},
{ ER_PORT_WHEN_HOST_NULL,
"\uD638\uC2A4\uD2B8\uAC00 \uB110\uC77C \uACBD\uC6B0 \uD3EC\uD2B8\uB97C \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_INVALID_PORT,
"\uD3EC\uD2B8 \uBC88\uD638\uAC00 \uBD80\uC801\uD569\uD569\uB2C8\uB2E4."},
{ ER_FRAG_FOR_GENERIC_URI,
"\uC77C\uBC18 URI\uC5D0 \uB300\uD574\uC11C\uB9CC \uBD80\uBD84\uC744 \uC124\uC815\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."},
{ ER_FRAG_WHEN_PATH_NULL,
"\uACBD\uB85C\uAC00 \uB110\uC77C \uACBD\uC6B0 \uBD80\uBD84\uC744 \uC124\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_FRAG_INVALID_CHAR,
"\uBD80\uBD84\uC5D0 \uBD80\uC801\uD569\uD55C \uBB38\uC790\uAC00 \uD3EC\uD568\uB418\uC5B4 \uC788\uC2B5\uB2C8\uB2E4."},
{ ER_PARSER_IN_USE,
"\uAD6C\uBB38 \uBD84\uC11D\uAE30\uAC00 \uC774\uBBF8 \uC0AC\uC6A9\uB418\uACE0 \uC788\uC2B5\uB2C8\uB2E4."},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"\uAD6C\uBB38 \uBD84\uC11D \uC911 {0} {1}\uC744(\uB97C) \uBCC0\uACBD\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"\uC790\uCCB4 \uC778\uACFC \uAD00\uACC4\uB294 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."},
{ ER_NO_USERINFO_IF_NO_HOST,
"\uD638\uC2A4\uD2B8\uB97C \uC9C0\uC815\uD558\uC9C0 \uC54A\uC740 \uACBD\uC6B0\uC5D0\uB294 Userinfo\uB97C \uC9C0\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_NO_PORT_IF_NO_HOST,
"\uD638\uC2A4\uD2B8\uB97C \uC9C0\uC815\uD558\uC9C0 \uC54A\uC740 \uACBD\uC6B0\uC5D0\uB294 \uD3EC\uD2B8\uB97C \uC9C0\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_NO_QUERY_STRING_IN_PATH,
"\uACBD\uB85C \uBC0F \uC9C8\uC758 \uBB38\uC790\uC5F4\uC5D0 \uC9C8\uC758 \uBB38\uC790\uC5F4\uC744 \uC9C0\uC815\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"\uACBD\uB85C\uC640 \uBD80\uBD84\uC5D0 \uBAA8\uB450 \uBD80\uBD84\uC744 \uC9C0\uC815\uD560 \uC218\uB294 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"\uBE48 \uB9E4\uAC1C\uBCC0\uC218\uB85C URI\uB97C \uCD08\uAE30\uD654\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_METHOD_NOT_SUPPORTED,
"\uBA54\uC18C\uB4DC\uAC00 \uC544\uC9C1 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"\uD604\uC7AC IncrementalSAXSource_Filter\uB97C \uC7AC\uC2DC\uC791\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"startParse \uC694\uCCAD \uC804\uC5D0 XMLReader\uAC00 \uC2E4\uD589\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"\uCD95 \uC21C\uD658\uAE30\uAC00 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC74C: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"\uB110 PrintWriter\uB85C ListingErrorHandler\uAC00 \uC0DD\uC131\uB418\uC5C8\uC2B5\uB2C8\uB2E4!"},
{ ER_SYSTEMID_UNKNOWN,
"SystemId\uB97C \uC54C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_LOCATION_UNKNOWN,
"\uC624\uB958 \uC704\uCE58\uB97C \uC54C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ ER_PREFIX_MUST_RESOLVE,
"\uC811\uB450\uC5B4\uB294 \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uB85C \uBD84\uC11D\uB418\uC5B4\uC57C \uD568: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"XPathContext\uC5D0\uC11C\uB294 createDocument()\uAC00 \uC9C0\uC6D0\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"\uC18D\uC131 \uD558\uC704\uC5D0 \uC18C\uC720\uC790 \uBB38\uC11C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"\uC18D\uC131 \uD558\uC704\uC5D0 \uC18C\uC720\uC790 \uBB38\uC11C \uC694\uC18C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"\uACBD\uACE0: \uBB38\uC11C \uC694\uC18C \uC55E\uC5D0 \uD14D\uC2A4\uD2B8\uB97C \uCD9C\uB825\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4! \uBB34\uC2DC\uD558\uB294 \uC911..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"DOM\uC5D0\uC11C \uB8E8\uD2B8\uB97C \uB450 \uAC1C \uC774\uC0C1 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4!"},
{ ER_ARG_LOCALNAME_NULL,
"'localName' \uC778\uC218\uAC00 \uB110\uC785\uB2C8\uB2E4."},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"QNAME\uC758 Localname\uC740 \uC801\uD569\uD55C NCName\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4."},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"QNAME\uC758 \uC811\uB450\uC5B4\uB294 \uC801\uD569\uD55C NCName\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4."},
{ ER_NAME_CANT_START_WITH_COLON,
"\uC774\uB984\uC740 \uCF5C\uB860\uC73C\uB85C \uC2DC\uC791\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4."},
{ "BAD_CODE", "createMessage\uC5D0 \uB300\uD55C \uB9E4\uAC1C\uBCC0\uC218\uAC00 \uBC94\uC704\uB97C \uBC97\uC5B4\uB0AC\uC2B5\uB2C8\uB2E4."},
{ "FORMAT_FAILED", "messageFormat \uD638\uCD9C \uC911 \uC608\uC678\uC0AC\uD56D\uC774 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4."},
{ "line", "\uD589 \uBC88\uD638"},
{ "column","\uC5F4 \uBC88\uD638"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"Serializer \uD074\uB798\uC2A4 ''{0}''\uC774(\uAC00) org.xml.sax.ContentHandler\uB97C \uAD6C\uD604\uD558\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4."},
{ER_RESOURCE_COULD_NOT_FIND,
"[{0}] \uB9AC\uC18C\uC2A4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"[{0}] \uB9AC\uC18C\uC2A4\uAC00 \uB2E4\uC74C\uC744 \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC74C: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"\uBC84\uD37C \uD06C\uAE30 <=0" },
{ER_INVALID_UTF16_SURROGATE,
"\uBD80\uC801\uD569\uD55C UTF-16 \uB300\uB9AC \uC694\uC18C\uAC00 \uAC10\uC9C0\uB428: {0}" },
{ER_OIERROR,
"IO \uC624\uB958" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"\uD558\uC704 \uB178\uB4DC\uAC00 \uC0DD\uC131\uB41C \uD6C4 \uB610\uB294 \uC694\uC18C\uAC00 \uC0DD\uC131\uB418\uAE30 \uC804\uC5D0 {0} \uC18D\uC131\uC744 \uCD94\uAC00\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uC18D\uC131\uC774 \uBB34\uC2DC\uB429\uB2C8\uB2E4."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"''{0}'' \uC811\uB450\uC5B4\uC5D0 \uB300\uD55C \uB124\uC784\uC2A4\uD398\uC774\uC2A4\uAC00 \uC120\uC5B8\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"''{0}'' \uC18D\uC131\uC774 \uC694\uC18C\uC5D0 \uD3EC\uD568\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"\uB124\uC784\uC2A4\uD398\uC774\uC2A4 \uC120\uC5B8 ''{0}''=''{1}''\uC774(\uAC00) \uC694\uC18C\uC5D0 \uD3EC\uD568\uB418\uC5B4 \uC788\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." },
{ER_COULD_NOT_LOAD_RESOURCE,
"{0}\uC744(\uB97C) \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. CLASSPATH\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624. \uD604\uC7AC \uAE30\uBCF8\uAC12\uB9CC \uC0AC\uC6A9\uD558\uB294 \uC911\uC785\uB2C8\uB2E4."},
{ ER_ILLEGAL_CHARACTER,
"{1}\uC758 \uC9C0\uC815\uB41C \uCD9C\uB825 \uC778\uCF54\uB529\uC5D0\uC11C \uD45C\uC2DC\uB418\uC9C0 \uC54A\uB294 \uC815\uC218 \uAC12 {0}\uC758 \uBB38\uC790\uB97C \uCD9C\uB825\uD558\uB824\uACE0 \uC2DC\uB3C4\uD588\uC2B5\uB2C8\uB2E4."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"\uCD9C\uB825 \uBA54\uC18C\uB4DC ''{1}''\uC5D0 \uB300\uD55C \uC18D\uC131 \uD30C\uC77C ''{0}''\uC744(\uB97C) \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. CLASSPATH\uB97C \uD655\uC778\uD558\uC2ED\uC2DC\uC624." }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_pt_BR extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Fun\u00E7\u00E3o n\u00E3o suportada!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"N\u00E3o \u00E9 poss\u00EDvel substituir a causa"},
{ ER_NO_DEFAULT_IMPL,
"Nenhuma implementa\u00E7\u00E3o padr\u00E3o encontrada "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) n\u00E3o suportado atualmente"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Deslocamento maior que o slot"},
{ ER_COROUTINE_NOT_AVAIL,
"Co-rotina n\u00E3o dispon\u00EDvel, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager recebeu a solicita\u00E7\u00E3o co_exit()"},
{ ER_COJOINROUTINESET_FAILED,
"Falha em co_joinCoroutineSet()"},
{ ER_COROUTINE_PARAM,
"Erro no par\u00E2metro da co-rotina ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nINESPERADO: Parser doTerminate responde {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"o parsing n\u00E3o pode ser chamado durante o parsing"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Erro: iterador digitado para o eixo {0} n\u00E3o implementado"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Erro: iterador para o eixo {0} n\u00E3o implementado "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"clonagem do iterador n\u00E3o suportada"},
{ ER_UNKNOWN_AXIS_TYPE,
"Tipo transversal de eixo desconhecido: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Transversor de eixo n\u00E3o suportado: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"N\u00E3o h\u00E1 mais IDs de DTM dispon\u00EDveis"},
{ ER_NOT_SUPPORTED,
"N\u00E3o suportado: {0}"},
{ ER_NODE_NON_NULL,
"O n\u00F3 deve ser n\u00E3o-nulo para getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"N\u00E3o foi poss\u00EDvel resolver o n\u00F3 para um handle"},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse n\u00E3o pode ser chamado durante o parsing"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse requer um SAXParser n\u00E3o nulo"},
{ ER_COULD_NOT_INIT_PARSER,
"n\u00E3o foi poss\u00EDvel inicializar o parser com"},
{ ER_EXCEPTION_CREATING_POOL,
"exce\u00E7\u00E3o ao criar a nova inst\u00E2ncia do pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"O caminho cont\u00E9m uma sequ\u00EAncia inv\u00E1lida de caracteres de escape"},
{ ER_SCHEME_REQUIRED,
"O esquema \u00E9 obrigat\u00F3rio!"},
{ ER_NO_SCHEME_IN_URI,
"Nenhum esquema encontrado no URI: {0}"},
{ ER_NO_SCHEME_INURI,
"Nenhum esquema encontrado no URI"},
{ ER_PATH_INVALID_CHAR,
"O caminho cont\u00E9m um caractere inv\u00E1lido: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"N\u00E3o \u00E9 poss\u00EDvel definir o esquema de uma string nula"},
{ ER_SCHEME_NOT_CONFORMANT,
"O esquema n\u00E3o \u00E9 compat\u00EDvel."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"O host n\u00E3o \u00E9 um endere\u00E7o correto"},
{ ER_PORT_WHEN_HOST_NULL,
"A porta n\u00E3o pode ser definida quando o host \u00E9 nulo"},
{ ER_INVALID_PORT,
"N\u00FAmero de porta inv\u00E1lido"},
{ ER_FRAG_FOR_GENERIC_URI,
"O fragmento s\u00F3 pode ser definido para um URI gen\u00E9rico"},
{ ER_FRAG_WHEN_PATH_NULL,
"O fragmento n\u00E3o pode ser definido quando o caminho \u00E9 nulo"},
{ ER_FRAG_INVALID_CHAR,
"O fragmento cont\u00E9m um caractere inv\u00E1lido"},
{ ER_PARSER_IN_USE,
"O parser j\u00E1 est\u00E1 sendo usado"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"N\u00E3o \u00E9 poss\u00EDvel alterar {0} {1} durante o parsing"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Autoaverigua\u00E7\u00E3o n\u00E3o permitida"},
{ ER_NO_USERINFO_IF_NO_HOST,
"As informa\u00E7\u00F5es do usu\u00E1rio n\u00E3o podem ser especificadas se o host n\u00E3o tiver sido especificado"},
{ ER_NO_PORT_IF_NO_HOST,
"A porta n\u00E3o pode ser especificada se o host n\u00E3o tiver sido especificado"},
{ ER_NO_QUERY_STRING_IN_PATH,
"A string de consulta n\u00E3o pode ser especificada no caminho nem na string de consulta"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"O fragmento n\u00E3o pode ser especificado no caminho nem no fragmento"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"N\u00E3o \u00E9 poss\u00EDvel inicializar o URI com par\u00E2metros vazios"},
{ ER_METHOD_NOT_SUPPORTED,
"M\u00E9todo ainda n\u00E3o suportado "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter atualmente n\u00E3o reinicializ\u00E1vel"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader n\u00E3o anterior \u00E0 solicita\u00E7\u00E3o de startParse"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Transversor de eixo n\u00E3o suportado: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler criado com PrintWriter nulo!"},
{ ER_SYSTEMID_UNKNOWN,
"SystemId Desconhecido"},
{ ER_LOCATION_UNKNOWN,
"Localiza\u00E7\u00E3o de erro desconhecida"},
{ ER_PREFIX_MUST_RESOLVE,
"O prefixo deve ser resolvido para um namespace: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() n\u00E3o suportado no XPathContext!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"O filho do atributo n\u00E3o tem um documento do propriet\u00E1rio!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"O filho do atributo n\u00E3o tem um elemento do documento do propriet\u00E1rio!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Advert\u00EAncia: n\u00E3o pode haver texto antes do elemento do documento! Ignorando..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"N\u00E3o pode ter mais de uma raiz em um DOM!"},
{ ER_ARG_LOCALNAME_NULL,
"O argumento 'localName' \u00E9 nulo"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Localname em QNAME deve ser um NCName v\u00E1lido"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"O prefixo em QNAME deve ser um NCName v\u00E1lido"},
{ ER_NAME_CANT_START_WITH_COLON,
"O nome n\u00E3o pode come\u00E7ar com dois pontos"},
{ "BAD_CODE", "O par\u00E2metro para createMessage estava fora dos limites"},
{ "FORMAT_FAILED", "Exce\u00E7\u00E3o gerada durante a chamada messageFormat"},
{ "line", "N\u00B0 da Linha"},
{ "column","N\u00B0 da Coluna"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"A classe ''{0}'' do serializador n\u00E3o implementa org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"N\u00E3o foi poss\u00EDvel encontrar o recurso [ {0} ].\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"O recurso [ {0} ] n\u00E3o foi carregado: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Tamanho do buffer <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Foi detectado um substituto de UTF-16 inv\u00E1lido: {0} ?" },
{ER_OIERROR,
"Erro de E/S" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"N\u00E3o \u00E9 poss\u00EDvel adicionar o atributo {0} depois dos n\u00F3s filhos ou antes que um elemento seja produzido. O atributo ser\u00E1 ignorado."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"O namespace do prefixo ''{0}'' n\u00E3o foi declarado." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Atributo ''{0}'' fora do elemento." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Declara\u00E7\u00E3o de namespace ''{0}''=''{1}'' fora do elemento." },
{ER_COULD_NOT_LOAD_RESOURCE,
"N\u00E3o foi poss\u00EDvel carregar ''{0}'' (verificar CLASSPATH); usando agora apenas os padr\u00F5es"},
{ ER_ILLEGAL_CHARACTER,
"Tentativa de exibir um caractere de valor integral {0} que n\u00E3o est\u00E1 representado na codifica\u00E7\u00E3o de sa\u00EDda especificada de {1}."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"N\u00E3o foi poss\u00EDvel carregar o arquivo de propriedade ''{0}'' para o m\u00E9todo de sa\u00EDda ''{1}'' (verificar CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,442 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_sk extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
private static final Object[][] _contents = new Object[][] {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Funkcia nie je podporovan\u00e1!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Nie je mo\u017en\u00e9 prep\u00edsa\u0165 pr\u00ed\u010dinu"},
{ ER_NO_DEFAULT_IMPL,
"Nebola n\u00e1jden\u00e1 \u017eiadna predvolen\u00e1 implement\u00e1cia "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) nie je moment\u00e1lne podporovan\u00fd"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Offset v\u00e4\u010d\u0161\u00ed, ne\u017e z\u00e1suvka"},
{ ER_COROUTINE_NOT_AVAIL,
"Korutina nie je dostupn\u00e1, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager obdr\u017eal po\u017eiadavku co_exit()"},
{ ER_COJOINROUTINESET_FAILED,
"zlyhal co_joinCoroutineSet()"},
{ ER_COROUTINE_PARAM,
"Chyba parametra korutiny ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nNEO\u010cAK\u00c1VAN\u00c9: Analyz\u00e1tor doTerminate odpoved\u00e1 {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"syntaktick\u00fd analyz\u00e1tor nem\u00f4\u017ee by\u0165 volan\u00fd po\u010das vykon\u00e1vania anal\u00fdzy"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Chyba: nap\u00edsan\u00fd iter\u00e1tor pre os {0} nie je implementovan\u00fd"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Chyba: iter\u00e1tor pre os {0} nie je implementovan\u00fd "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Klon iter\u00e1tora nie je podporovan\u00fd"},
{ ER_UNKNOWN_AXIS_TYPE,
"Nezn\u00e1my typ pret\u00ednania os\u00ed: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Pret\u00ednanie os\u00ed nie je podporovan\u00e9: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"\u017diadne \u010fal\u0161ie DTM ID nie s\u00fa dostupn\u00e9"},
{ ER_NOT_SUPPORTED,
"Nie je podporovan\u00e9: {0}"},
{ ER_NODE_NON_NULL,
"Pre getDTMHandleFromNode mus\u00ed by\u0165 uzol nenulov\u00fd"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Nebolo mo\u017en\u00e9 ur\u010di\u0165 uzol na spracovanie"},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse nem\u00f4\u017ee by\u0165 volan\u00fd po\u010das vykon\u00e1vania anal\u00fdzy"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse potrebuje nenulov\u00fd SAXParser"},
{ ER_COULD_NOT_INIT_PARSER,
"nebolo mo\u017en\u00e9 inicializova\u0165 syntaktick\u00fd analyz\u00e1tor pomocou"},
{ ER_EXCEPTION_CREATING_POOL,
"v\u00fdnimka vytv\u00e1rania novej in\u0161tancie oblasti"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Cesta obsahuje neplatn\u00fa \u00fanikov\u00fa sekvenciu"},
{ ER_SCHEME_REQUIRED,
"Je po\u017eadovan\u00e1 sch\u00e9ma!"},
{ ER_NO_SCHEME_IN_URI,
"V URI sa nena\u0161la \u017eiadna sch\u00e9ma: {0}"},
{ ER_NO_SCHEME_INURI,
"V URI nebola n\u00e1jden\u00e1 \u017eiadna sch\u00e9ma"},
{ ER_PATH_INVALID_CHAR,
"Cesta obsahuje neplatn\u00fd znak: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Nie je mo\u017en\u00e9 stanovi\u0165 sch\u00e9mu z nulov\u00e9ho re\u0165azca"},
{ ER_SCHEME_NOT_CONFORMANT,
"Nezhodn\u00e1 sch\u00e9ma."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Hostite\u013e nie je spr\u00e1vne form\u00e1tovan\u00e1 adresa"},
{ ER_PORT_WHEN_HOST_NULL,
"Nem\u00f4\u017ee by\u0165 stanoven\u00fd port, ak je hostite\u013e null"},
{ ER_INVALID_PORT,
"Neplatn\u00e9 \u010d\u00edslo portu"},
{ ER_FRAG_FOR_GENERIC_URI,
"Fragment m\u00f4\u017ee by\u0165 stanoven\u00fd len pre v\u0161eobecn\u00e9 URI"},
{ ER_FRAG_WHEN_PATH_NULL,
"Ak je cesta nulov\u00e1, nem\u00f4\u017ee by\u0165 stanoven\u00fd fragment"},
{ ER_FRAG_INVALID_CHAR,
"Fragment obsahuje neplatn\u00fd znak"},
{ ER_PARSER_IN_USE,
"Syntaktick\u00fd analyz\u00e1tor je u\u017e pou\u017e\u00edvan\u00fd"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"Nie je mo\u017en\u00e9 zmeni\u0165 {0} {1} po\u010das vykon\u00e1vania anal\u00fdzy"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Samozapr\u00ed\u010dinenie nie je povolen\u00e9"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Ak nebol zadan\u00fd hostite\u013e, mo\u017eno nebolo zadan\u00e9 userinfo"},
{ ER_NO_PORT_IF_NO_HOST,
"Ak nebol zadan\u00fd hostite\u013e, mo\u017eno nebol zadan\u00fd port"},
{ ER_NO_QUERY_STRING_IN_PATH,
"Re\u0165azec dotazu nem\u00f4\u017ee by\u0165 zadan\u00fd v ceste a re\u0165azci dotazu"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Fragment nem\u00f4\u017ee by\u0165 zadan\u00fd v ceste, ani vo fragmente"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"Nie je mo\u017en\u00e9 inicializova\u0165 URI s pr\u00e1zdnymi parametrami"},
{ ER_METHOD_NOT_SUPPORTED,
"Met\u00f3da e\u0161te nie je podporovan\u00e1 "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter nie je moment\u00e1lne re\u0161tartovate\u013en\u00fd"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader nepredch\u00e1dza po\u017eiadavke na startParse"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Pret\u00ednanie os\u00ed nie je podporovan\u00e9: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler vytvoren\u00fd s nulov\u00fdm PrintWriter!"},
{ ER_SYSTEMID_UNKNOWN,
"Nezn\u00e1me SystemId"},
{ ER_LOCATION_UNKNOWN,
"Nezn\u00e1me miesto v\u00fdskytu chyby"},
{ ER_PREFIX_MUST_RESOLVE,
"Predpona sa mus\u00ed rozl\u00ed\u0161i\u0165 do n\u00e1zvov\u00e9ho priestoru: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() nie je podporovan\u00e9 XPathContext!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"Potomok atrib\u00fatu nem\u00e1 dokument vlastn\u00edka!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"Potomok atrib\u00fatu nem\u00e1 s\u00fa\u010das\u0165 dokumentu vlastn\u00edka!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Upozornenie: nemo\u017eno vypusti\u0165 text pred elementom dokumentu! Ignorovanie..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"Nie je mo\u017en\u00e9 ma\u0165 viac, ne\u017e jeden kore\u0148 DOM!"},
{ ER_ARG_LOCALNAME_NULL,
"Argument 'localName' je null"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Lok\u00e1lny n\u00e1zov v QNAME by mal by\u0165 platn\u00fdm NCName"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"Predpona v QNAME by mala by\u0165 platn\u00fdm NCName"},
{ "BAD_CODE", "Parameter na createMessage bol mimo ohrani\u010denia"},
{ "FORMAT_FAILED", "V\u00fdnimka po\u010das volania messageFormat"},
{ "line", "Riadok #"},
{ "column","St\u013apec #"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"Trieda serializ\u00e1tora ''{0}'' neimplementuje org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"Prostriedok [ {0} ] nemohol by\u0165 n\u00e1jden\u00fd.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"Prostriedok [ {0} ] sa nedal na\u010d\u00edta\u0165: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Ve\u013ekos\u0165 vyrovn\u00e1vacej pam\u00e4te <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Bolo zisten\u00e9 neplatn\u00e9 nahradenie UTF-16: {0} ?" },
{ER_OIERROR,
"chyba IO" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Nie je mo\u017en\u00e9 prida\u0165 atrib\u00fat {0} po uzloch potomka alebo pred vytvoren\u00edm elementu. Atrib\u00fat bude ignorovan\u00fd."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"N\u00e1zvov\u00fd priestor pre predponu ''{0}'' nebol deklarovan\u00fd." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Atrib\u00fat ''{0}'' je mimo elementu." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Deklar\u00e1cia n\u00e1zvov\u00e9ho priestoru ''{0}''=''{1}'' je mimo elementu." },
{ER_COULD_NOT_LOAD_RESOURCE,
"Nedalo sa na\u010d\u00edta\u0165 ''{0}'' (skontrolujte CLASSPATH), pou\u017e\u00edvaj\u00fa sa predvolen\u00e9 hodnoty"},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Nedal sa na\u010d\u00edta\u0165 s\u00fabor vlastnost\u00ed ''{0}'' pre v\u00fdstupn\u00fa met\u00f3du ''{1}'' (skontrolujte CLASSPATH)" }
};
/**
* Get the lookup table for error messages
*
* @return The association list.
*/
public Object[][] getContents()
{
return _contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_sv extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"Funktionen st\u00F6ds inte!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Orsak kan inte skrivas \u00F6ver"},
{ ER_NO_DEFAULT_IMPL,
"Hittade ingen standardimplementering "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) underst\u00F6ds f\u00F6r n\u00E4rvarande inte"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"Offset st\u00F6rre \u00E4n plats"},
{ ER_COROUTINE_NOT_AVAIL,
"Sidorutin \u00E4r inte tillg\u00E4nglig, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager har tagit emot co_exit()-beg\u00E4ran"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() utf\u00F6rdes inte"},
{ ER_COROUTINE_PARAM,
"Parameterfel f\u00F6r sidorutin ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nUNEXPECTED: Parsersvar {0} f\u00F6r doTerminate"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"parse f\u00E5r inte anropas medan tolkning sker"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Fel: typad iterator f\u00F6r axeln {0} har inte implementerats"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Fel: iterator f\u00F6r axeln {0} har inte implementerats "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Iteratorklon underst\u00F6ds inte"},
{ ER_UNKNOWN_AXIS_TYPE,
"Ok\u00E4nd axeltraverstyp: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Axeltravers underst\u00F6ds inte: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"Inga fler DTM-id:n \u00E4r tillg\u00E4ngliga"},
{ ER_NOT_SUPPORTED,
"Underst\u00F6ds inte: {0}"},
{ ER_NODE_NON_NULL,
"Nod m\u00E5ste vara icke-null f\u00F6r getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"Kunde inte matcha noden med en referens"},
{ ER_STARTPARSE_WHILE_PARSING,
"startParse f\u00E5r inte anropas medan tolkning sker"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse beh\u00F6ver en SAXParser som \u00E4r icke-null"},
{ ER_COULD_NOT_INIT_PARSER,
"kunde inte initiera parser med"},
{ ER_EXCEPTION_CREATING_POOL,
"undantag skapar ny instans f\u00F6r pool"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"S\u00F6kv\u00E4gen inneh\u00E5ller en ogiltig escape-sekvens"},
{ ER_SCHEME_REQUIRED,
"Schema kr\u00E4vs!"},
{ ER_NO_SCHEME_IN_URI,
"Schema saknas i URI: {0}"},
{ ER_NO_SCHEME_INURI,
"Schema saknas i URI"},
{ ER_PATH_INVALID_CHAR,
"S\u00F6kv\u00E4gen inneh\u00E5ller ett ogiltigt tecken: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Kan inte st\u00E4lla in schema fr\u00E5n null-str\u00E4ng"},
{ ER_SCHEME_NOT_CONFORMANT,
"Schemat \u00E4r inte likformigt."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"V\u00E4rd \u00E4r inte en v\u00E4lformulerad adress"},
{ ER_PORT_WHEN_HOST_NULL,
"Port kan inte st\u00E4llas in n\u00E4r v\u00E4rd \u00E4r null"},
{ ER_INVALID_PORT,
"Ogiltigt portnummer"},
{ ER_FRAG_FOR_GENERIC_URI,
"Fragment kan bara st\u00E4llas in f\u00F6r en allm\u00E4n URI"},
{ ER_FRAG_WHEN_PATH_NULL,
"Fragment kan inte st\u00E4llas in n\u00E4r s\u00F6kv\u00E4g \u00E4r null"},
{ ER_FRAG_INVALID_CHAR,
"Fragment inneh\u00E5ller ett ogiltigt tecken"},
{ ER_PARSER_IN_USE,
"Parser anv\u00E4nds redan"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"Kan inte \u00E4ndra {0} {1} medan tolkning sker"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"Sj\u00E4lvorsakande inte till\u00E5ten"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Anv\u00E4ndarinfo f\u00E5r inte anges om v\u00E4rden inte \u00E4r angiven"},
{ ER_NO_PORT_IF_NO_HOST,
"Port f\u00E5r inte anges om v\u00E4rden inte \u00E4r angiven"},
{ ER_NO_QUERY_STRING_IN_PATH,
"Fr\u00E5gestr\u00E4ng kan inte anges i b\u00E5de s\u00F6kv\u00E4gen och fr\u00E5gestr\u00E4ngen"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Fragment kan inte anges i b\u00E5de s\u00F6kv\u00E4gen och fragmentet"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"Kan inte initiera URI med tomma parametrar"},
{ ER_METHOD_NOT_SUPPORTED,
"Metoden st\u00F6ds \u00E4nnu inte "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter kan f\u00F6r n\u00E4rvarande inte startas om"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader inte f\u00F6re startParse-beg\u00E4ran"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Axeltravers underst\u00F6ds inte: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler skapad med null PrintWriter!"},
{ ER_SYSTEMID_UNKNOWN,
"SystemId ok\u00E4nt"},
{ ER_LOCATION_UNKNOWN,
"Platsen f\u00F6r felet \u00E4r ok\u00E4nd"},
{ ER_PREFIX_MUST_RESOLVE,
"Prefix m\u00E5ste matchas till en namnrymd: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"createDocument() st\u00F6ds inte i XPathContext!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"Underordnat attribut har inget \u00E4gardokument!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"Underordnat attribut har inget \u00E4gardokumentelement!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Varning: utdatatext kan inte skrivas ut f\u00F6re dokumentelement! Ignoreras..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"En DOM kan inte ha fler \u00E4n en rot!"},
{ ER_ARG_LOCALNAME_NULL,
"Argumentet 'localName' \u00E4r null"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"Localname i QNAME b\u00F6r vara giltigt NCName"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"Prefix i QNAME b\u00F6r vara giltigt NCName"},
{ ER_NAME_CANT_START_WITH_COLON,
"Namnet kan inte b\u00F6rja med kolon"},
{ "BAD_CODE", "Parameter f\u00F6r createMessage ligger utanf\u00F6r gr\u00E4nsv\u00E4rdet"},
{ "FORMAT_FAILED", "Undantag utl\u00F6st vid messageFormat-anrop"},
{ "line", "Rad nr"},
{ "column","Kolumn nr"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"Serializerklassen ''{0}'' implementerar inte org.xml.sax.ContentHandler."},
{ER_RESOURCE_COULD_NOT_FIND,
"Resursen [ {0} ] kunde inte h\u00E4mtas.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"Resursen [ {0} ] kunde inte laddas: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Buffertstorlek <=0" },
{ER_INVALID_UTF16_SURROGATE,
"Ogiltigt UTF-16-surrogat uppt\u00E4ckt: {0} ?" },
{ER_OIERROR,
"IO-fel" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Kan inte l\u00E4gga till attributet {0} efter underordnade noder eller innan ett element har skapats. Attributet ignoreras."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"Namnrymd f\u00F6r prefix ''{0}'' har inte deklarerats." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"Attributet ''{0}'' finns utanf\u00F6r elementet." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"Namnrymdsdeklarationen ''{0}''=''{1}'' finns utanf\u00F6r element." },
{ER_COULD_NOT_LOAD_RESOURCE,
"Kunde inte ladda ''{0}'' (kontrollera CLASSPATH), anv\u00E4nder nu enbart standardv\u00E4rden"},
{ ER_ILLEGAL_CHARACTER,
"F\u00F6rs\u00F6k att skriva utdatatecken med integralv\u00E4rdet {0} som inte \u00E4r representerat i angiven utdatakodning av {1}."},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"Kunde inte ladda egenskapsfilen ''{0}'' f\u00F6r utdatametoden ''{1}'' (kontrollera CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,442 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_tr extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
private static final Object[][] _contents = new Object[][] {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"\u0130\u015flev desteklenmiyor!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"Nedenin \u00fczerine yaz\u0131lamaz"},
{ ER_NO_DEFAULT_IMPL,
"Varsay\u0131lan uygulama bulunamad\u0131"},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"ChunkedIntArray({0}) \u015fu an desteklenmiyor"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"G\u00f6reli konum yuvadan b\u00fcy\u00fck"},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine kullan\u0131lam\u0131yor, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager co_exit() iste\u011fi ald\u0131"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() ba\u015far\u0131s\u0131z oldu"},
{ ER_COROUTINE_PARAM,
"Coroutine de\u011fi\u015ftirgesi hatas\u0131 ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\nBEKLENMEYEN: Parser doTerminate yan\u0131t\u0131 {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"Ayr\u0131\u015ft\u0131rma s\u0131ras\u0131nda parse \u00e7a\u011fr\u0131lamaz"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Hata: {0} ekseni i\u00e7in tip atanm\u0131\u015f yineleyici ger\u00e7ekle\u015ftirilmedi"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"Hata: {0} ekseni i\u00e7in yineleyici ger\u00e7ekle\u015ftirilmedi"},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"Yineleyici e\u015fkopyas\u0131 desteklenmiyor"},
{ ER_UNKNOWN_AXIS_TYPE,
"Bilinmeyen eksen dola\u015fma tipi: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"Eksen dola\u015f\u0131c\u0131 desteklenmiyor: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"Kullan\u0131labilecek ba\u015fka DTM tan\u0131t\u0131c\u0131s\u0131 yok"},
{ ER_NOT_SUPPORTED,
"Desteklenmiyor: {0}"},
{ ER_NODE_NON_NULL,
"getDTMHandleFromNode i\u00e7in d\u00fc\u011f\u00fcm bo\u015f de\u011ferli olmamal\u0131d\u0131r"},
{ ER_COULD_NOT_RESOLVE_NODE,
"D\u00fc\u011f\u00fcm tan\u0131t\u0131c\u0131 de\u011fere \u00e7\u00f6z\u00fclemedi"},
{ ER_STARTPARSE_WHILE_PARSING,
"Ayr\u0131\u015ft\u0131rma s\u0131ras\u0131nda startParse \u00e7a\u011fr\u0131lamaz"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse i\u00e7in bo\u015f de\u011ferli olmayan SAXParser gerekiyor"},
{ ER_COULD_NOT_INIT_PARSER,
"Ayr\u0131\u015ft\u0131r\u0131c\u0131 bununla kullan\u0131ma haz\u0131rlanamad\u0131"},
{ ER_EXCEPTION_CREATING_POOL,
"Havuz i\u00e7in yeni \u00f6rnek yarat\u0131l\u0131rken kural d\u0131\u015f\u0131 durum"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"Yol ge\u00e7ersiz ka\u00e7\u0131\u015f dizisi i\u00e7eriyor"},
{ ER_SCHEME_REQUIRED,
"\u015eema gerekli!"},
{ ER_NO_SCHEME_IN_URI,
"URI i\u00e7inde \u015fema bulunamad\u0131: {0}"},
{ ER_NO_SCHEME_INURI,
"URI i\u00e7inde \u015fema bulunamad\u0131"},
{ ER_PATH_INVALID_CHAR,
"Yol ge\u00e7ersiz karakter i\u00e7eriyor: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"Bo\u015f de\u011ferli dizgiden \u015fema tan\u0131mlanamaz"},
{ ER_SCHEME_NOT_CONFORMANT,
"\u015eema uyumlu de\u011fil."},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"Anasistem do\u011fru bi\u00e7imli bir adres de\u011fil"},
{ ER_PORT_WHEN_HOST_NULL,
"Anasistem bo\u015f de\u011ferliyken kap\u0131 tan\u0131mlanamaz"},
{ ER_INVALID_PORT,
"Kap\u0131 numaras\u0131 ge\u00e7ersiz"},
{ ER_FRAG_FOR_GENERIC_URI,
"Par\u00e7a yaln\u0131zca soysal URI i\u00e7in tan\u0131mlanabilir"},
{ ER_FRAG_WHEN_PATH_NULL,
"Yol bo\u015f de\u011ferliyken par\u00e7a tan\u0131mlanamaz"},
{ ER_FRAG_INVALID_CHAR,
"Par\u00e7a ge\u00e7ersiz karakter i\u00e7eriyor"},
{ ER_PARSER_IN_USE,
"Ayr\u0131\u015ft\u0131r\u0131c\u0131 kullan\u0131mda"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"Ayr\u0131\u015ft\u0131rma s\u0131ras\u0131nda {0} {1} de\u011fi\u015ftirilemez"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"\u00d6znedenselli\u011fe izin verilmez"},
{ ER_NO_USERINFO_IF_NO_HOST,
"Anasistem belirtilmediyse kullan\u0131c\u0131 bilgisi belirtilemez"},
{ ER_NO_PORT_IF_NO_HOST,
"Anasistem belirtilmediyse kap\u0131 belirtilemez"},
{ ER_NO_QUERY_STRING_IN_PATH,
"Yol ve sorgu dizgisinde sorgu dizgisi belirtilemez"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"Par\u00e7a hem yolda, hem de par\u00e7ada belirtilemez"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"Bo\u015f de\u011fi\u015ftirgelerle URI kullan\u0131ma haz\u0131rlanamaz"},
{ ER_METHOD_NOT_SUPPORTED,
"Y\u00f6ntem hen\u00fcz desteklenmiyor"},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter \u015fu an yeniden ba\u015flat\u0131labilir durumda de\u011fil"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader, startParse iste\u011finden \u00f6nce olmaz"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"Eksen dola\u015f\u0131c\u0131 desteklenmiyor: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"ListingErrorHandler bo\u015f de\u011ferli PrintWriter ile yarat\u0131ld\u0131!"},
{ ER_SYSTEMID_UNKNOWN,
"SystemId bilinmiyor"},
{ ER_LOCATION_UNKNOWN,
"Hata yeri bilinmiyor"},
{ ER_PREFIX_MUST_RESOLVE,
"\u00d6nek bir ad alan\u0131na \u00e7\u00f6z\u00fclmelidir: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"XPathContext i\u00e7inde createDocument() desteklenmiyor!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"\u00d6zniteli\u011fin alt \u00f6\u011fesinin iye belgesi yok!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"\u00d6zniteli\u011fin alt \u00f6\u011fesinin iye belge \u00f6\u011fesi yok!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"Uyar\u0131: Belge \u00f6\u011fesinden \u00f6nce metin \u00e7\u0131k\u0131\u015f\u0131 olamaz! Yoksay\u0131l\u0131yor..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"DOM \u00fczerinde birden fazla k\u00f6k olamaz!"},
{ ER_ARG_LOCALNAME_NULL,
"'localName' ba\u011f\u0131ms\u0131z de\u011fi\u015ftirgesi bo\u015f de\u011ferli"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"QNAME i\u00e7indeki yerel ad (localname) ge\u00e7erli bir NCName olmal\u0131d\u0131r"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"QNAME i\u00e7indeki \u00f6nek ge\u00e7erli bir NCName olmal\u0131d\u0131r"},
{ "BAD_CODE", "createMessage i\u00e7in kullan\u0131lan de\u011fi\u015ftirge s\u0131n\u0131rlar\u0131n d\u0131\u015f\u0131nda"},
{ "FORMAT_FAILED", "messageFormat \u00e7a\u011fr\u0131s\u0131 s\u0131ras\u0131nda kural d\u0131\u015f\u0131 durum yay\u0131nland\u0131"},
{ "line", "Sat\u0131r #"},
{ "column","Kolon #"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"Diziselle\u015ftirici s\u0131n\u0131f\u0131 ''{0}'' org.xml.sax.ContentHandler i\u015flevini uygulam\u0131yor."},
{ER_RESOURCE_COULD_NOT_FIND,
"Kaynak [ {0} ] bulunamad\u0131.\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"Kaynak [ {0} ] y\u00fckleyemedi: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"Arabellek b\u00fcy\u00fckl\u00fc\u011f\u00fc <=0" },
{ER_INVALID_UTF16_SURROGATE,
"UTF-16 yerine kullan\u0131lan de\u011fer ge\u00e7ersiz: {0} ?" },
{ER_OIERROR,
"G\u00c7 hatas\u0131" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"Alt d\u00fc\u011f\u00fcmlerden sonra ya da bir \u00f6\u011fe \u00fcretilmeden \u00f6nce {0} \u00f6zniteli\u011fi eklenemez. \u00d6znitelik yoksay\u0131lacak."},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"''{0}'' \u00f6nekine ili\u015fkin ad alan\u0131 bildirilmedi." },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"''{0}'' \u00f6zniteli\u011fi \u00f6\u011fenin d\u0131\u015f\u0131nda." },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"''{0}''=''{1}'' ad alan\u0131 bildirimi \u00f6\u011fenin d\u0131\u015f\u0131nda." },
{ER_COULD_NOT_LOAD_RESOURCE,
"''{0}'' y\u00fcklenemedi (CLASSPATH de\u011fi\u015fkeninizi inceleyin), yaln\u0131zca varsay\u0131lanlar kullan\u0131l\u0131yor"},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"''{1}'' \u00e7\u0131k\u0131\u015f y\u00f6ntemi i\u00e7in ''{0}'' \u00f6zellik dosyas\u0131 y\u00fcklenemedi (CLASSPATH de\u011fi\u015fkenini inceleyin)" }
};
/**
* Get the lookup table for error messages
*
* @return The association list.
*/
public Object[][] getContents()
{
return _contents;
}
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_zh_CN extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"\u4E0D\u652F\u6301\u8BE5\u51FD\u6570!"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"\u65E0\u6CD5\u8986\u76D6\u539F\u56E0"},
{ ER_NO_DEFAULT_IMPL,
"\u627E\u4E0D\u5230\u9ED8\u8BA4\u5B9E\u73B0 "},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"\u5F53\u524D\u4E0D\u652F\u6301 ChunkedIntArray({0})"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"\u504F\u79FB\u91CF\u5927\u4E8E\u63D2\u69FD"},
{ ER_COROUTINE_NOT_AVAIL,
"Coroutine \u4E0D\u53EF\u7528, id={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager \u6536\u5230 co_exit() \u8BF7\u6C42"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() \u5931\u8D25"},
{ ER_COROUTINE_PARAM,
"Coroutine \u53C2\u6570\u9519\u8BEF ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\n\u610F\u5916: \u89E3\u6790\u5668\u5BF9\u7B54\u590D{0}\u6267\u884C doTerminate"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"\u65E0\u6CD5\u5728\u89E3\u6790\u65F6\u8C03\u7528 parse"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\u9519\u8BEF: \u672A\u5B9E\u73B0\u8F74{0}\u7684\u7C7B\u578B\u5316\u8FED\u4EE3\u5668"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\u9519\u8BEF: \u672A\u5B9E\u73B0\u8F74{0}\u7684\u8FED\u4EE3\u5668 "},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"\u4E0D\u652F\u6301\u514B\u9686\u8FED\u4EE3\u5668"},
{ ER_UNKNOWN_AXIS_TYPE,
"\u8F74\u904D\u5386\u7C7B\u578B\u672A\u77E5: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"\u4E0D\u652F\u6301\u8F74\u904D\u5386\u7A0B\u5E8F: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"\u65E0\u6CD5\u4F7F\u7528\u66F4\u591A DTM ID"},
{ ER_NOT_SUPPORTED,
"\u4E0D\u652F\u6301: {0}"},
{ ER_NODE_NON_NULL,
"getDTMHandleFromNode \u7684\u8282\u70B9\u5FC5\u987B\u4E3A\u975E\u7A7A\u503C"},
{ ER_COULD_NOT_RESOLVE_NODE,
"\u65E0\u6CD5\u5C06\u8282\u70B9\u89E3\u6790\u4E3A\u53E5\u67C4"},
{ ER_STARTPARSE_WHILE_PARSING,
"\u65E0\u6CD5\u5728\u89E3\u6790\u65F6\u8C03\u7528 startParse"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse \u9700\u8981\u975E\u7A7A SAXParser"},
{ ER_COULD_NOT_INIT_PARSER,
"\u65E0\u6CD5\u4F7F\u7528\u4EE5\u4E0B\u5BF9\u8C61\u521D\u59CB\u5316\u89E3\u6790\u5668"},
{ ER_EXCEPTION_CREATING_POOL,
"\u4E3A\u6C60\u521B\u5EFA\u65B0\u5B9E\u4F8B\u65F6\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"\u8DEF\u5F84\u5305\u542B\u65E0\u6548\u7684\u8F6C\u4E49\u5E8F\u5217"},
{ ER_SCHEME_REQUIRED,
"\u65B9\u6848\u662F\u5FC5\u9700\u7684!"},
{ ER_NO_SCHEME_IN_URI,
"\u5728 URI \u4E2D\u627E\u4E0D\u5230\u65B9\u6848: {0}"},
{ ER_NO_SCHEME_INURI,
"\u5728 URI \u4E2D\u627E\u4E0D\u5230\u65B9\u6848"},
{ ER_PATH_INVALID_CHAR,
"\u8DEF\u5F84\u5305\u542B\u65E0\u6548\u7684\u5B57\u7B26: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"\u65E0\u6CD5\u4ECE\u7A7A\u5B57\u7B26\u4E32\u8BBE\u7F6E\u65B9\u6848"},
{ ER_SCHEME_NOT_CONFORMANT,
"\u65B9\u6848\u4E0D\u4E00\u81F4\u3002"},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"\u4E3B\u673A\u4E0D\u662F\u683C\u5F0F\u826F\u597D\u7684\u5730\u5740"},
{ ER_PORT_WHEN_HOST_NULL,
"\u4E3B\u673A\u4E3A\u7A7A\u65F6, \u65E0\u6CD5\u8BBE\u7F6E\u7AEF\u53E3"},
{ ER_INVALID_PORT,
"\u65E0\u6548\u7684\u7AEF\u53E3\u53F7"},
{ ER_FRAG_FOR_GENERIC_URI,
"\u53EA\u80FD\u4E3A\u4E00\u822C URI \u8BBE\u7F6E\u7247\u6BB5"},
{ ER_FRAG_WHEN_PATH_NULL,
"\u8DEF\u5F84\u4E3A\u7A7A\u65F6, \u65E0\u6CD5\u8BBE\u7F6E\u7247\u6BB5"},
{ ER_FRAG_INVALID_CHAR,
"\u7247\u6BB5\u5305\u542B\u65E0\u6548\u7684\u5B57\u7B26"},
{ ER_PARSER_IN_USE,
"\u89E3\u6790\u5668\u5DF2\u5728\u4F7F\u7528"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"\u65E0\u6CD5\u5728\u89E3\u6790\u65F6\u66F4\u6539{0} {1}"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"\u4E0D\u5141\u8BB8\u4F7F\u7528\u81EA\u56E0"},
{ ER_NO_USERINFO_IF_NO_HOST,
"\u5982\u679C\u6CA1\u6709\u6307\u5B9A\u4E3B\u673A, \u5219\u4E0D\u53EF\u4EE5\u6307\u5B9A Userinfo"},
{ ER_NO_PORT_IF_NO_HOST,
"\u5982\u679C\u6CA1\u6709\u6307\u5B9A\u4E3B\u673A, \u5219\u4E0D\u53EF\u4EE5\u6307\u5B9A\u7AEF\u53E3"},
{ ER_NO_QUERY_STRING_IN_PATH,
"\u8DEF\u5F84\u548C\u67E5\u8BE2\u5B57\u7B26\u4E32\u4E2D\u4E0D\u80FD\u6307\u5B9A\u67E5\u8BE2\u5B57\u7B26\u4E32"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"\u8DEF\u5F84\u548C\u7247\u6BB5\u4E2D\u90FD\u65E0\u6CD5\u6307\u5B9A\u7247\u6BB5"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"\u65E0\u6CD5\u4EE5\u7A7A\u53C2\u6570\u521D\u59CB\u5316 URI"},
{ ER_METHOD_NOT_SUPPORTED,
"\u5C1A\u4E0D\u652F\u6301\u8BE5\u65B9\u6CD5 "},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"\u5F53\u524D\u65E0\u6CD5\u91CD\u65B0\u542F\u52A8 IncrementalSAXSource_Filter"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader \u4E0D\u5728 startParse \u8BF7\u6C42\u4E4B\u524D"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"\u4E0D\u652F\u6301\u8F74\u904D\u5386\u7A0B\u5E8F: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"\u4F7F\u7528\u7A7A PrintWriter \u521B\u5EFA\u4E86 ListingErrorHandler!"},
{ ER_SYSTEMID_UNKNOWN,
"SystemId \u672A\u77E5"},
{ ER_LOCATION_UNKNOWN,
"\u9519\u8BEF\u6240\u5728\u7684\u4F4D\u7F6E\u672A\u77E5"},
{ ER_PREFIX_MUST_RESOLVE,
"\u524D\u7F00\u5FC5\u987B\u89E3\u6790\u4E3A\u540D\u79F0\u7A7A\u95F4: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"XPathContext \u4E2D\u4E0D\u652F\u6301 createDocument()!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"\u5C5E\u6027\u5B50\u7EA7\u6CA1\u6709\u6240\u6709\u8005\u6587\u6863!"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"\u5C5E\u6027\u5B50\u7EA7\u6CA1\u6709\u6240\u6709\u8005\u6587\u6863\u5143\u7D20!"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"\u8B66\u544A: \u65E0\u6CD5\u8F93\u51FA\u6587\u6863\u5143\u7D20\u4E4B\u524D\u7684\u6587\u672C! \u5C06\u5FFD\u7565..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"DOM \u4E0A\u4E0D\u80FD\u6709\u591A\u4E2A\u6839!"},
{ ER_ARG_LOCALNAME_NULL,
"\u53C2\u6570 'localName' \u4E3A\u7A7A\u503C"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"QNAME \u4E2D\u7684\u672C\u5730\u540D\u79F0\u5E94\u4E3A\u6709\u6548 NCName"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"QNAME \u4E2D\u7684\u524D\u7F00\u5E94\u4E3A\u6709\u6548 NCName"},
{ ER_NAME_CANT_START_WITH_COLON,
"\u540D\u79F0\u4E0D\u80FD\u4EE5\u5192\u53F7\u5F00\u5934"},
{ "BAD_CODE", "createMessage \u7684\u53C2\u6570\u8D85\u51FA\u8303\u56F4"},
{ "FORMAT_FAILED", "\u8C03\u7528 messageFormat \u65F6\u629B\u51FA\u5F02\u5E38\u9519\u8BEF"},
{ "line", "\u884C\u53F7"},
{ "column","\u5217\u53F7"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"\u4E32\u884C\u5668\u7C7B ''{0}'' \u4E0D\u5B9E\u73B0 org.xml.sax.ContentHandler\u3002"},
{ER_RESOURCE_COULD_NOT_FIND,
"\u627E\u4E0D\u5230\u8D44\u6E90 [ {0} ]\u3002\n {1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"\u8D44\u6E90 [ {0} ] \u65E0\u6CD5\u52A0\u8F7D: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"\u7F13\u51B2\u533A\u5927\u5C0F <=0" },
{ER_INVALID_UTF16_SURROGATE,
"\u68C0\u6D4B\u5230\u65E0\u6548\u7684 UTF-16 \u4EE3\u7406: {0}?" },
{ER_OIERROR,
"IO \u9519\u8BEF" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"\u5728\u751F\u6210\u5B50\u8282\u70B9\u4E4B\u540E\u6216\u5728\u751F\u6210\u5143\u7D20\u4E4B\u524D\u65E0\u6CD5\u6DFB\u52A0\u5C5E\u6027 {0}\u3002\u5C06\u5FFD\u7565\u5C5E\u6027\u3002"},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"\u6CA1\u6709\u8BF4\u660E\u540D\u79F0\u7A7A\u95F4\u524D\u7F00 ''{0}''\u3002" },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"\u5C5E\u6027 ''{0}'' \u5728\u5143\u7D20\u5916\u90E8\u3002" },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"\u540D\u79F0\u7A7A\u95F4\u58F0\u660E ''{0}''=''{1}'' \u5728\u5143\u7D20\u5916\u90E8\u3002" },
{ER_COULD_NOT_LOAD_RESOURCE,
"\u65E0\u6CD5\u52A0\u8F7D ''{0}'' (\u68C0\u67E5 CLASSPATH), \u73B0\u5728\u53EA\u4F7F\u7528\u9ED8\u8BA4\u503C"},
{ ER_ILLEGAL_CHARACTER,
"\u5C1D\u8BD5\u8F93\u51FA\u672A\u4EE5{1}\u7684\u6307\u5B9A\u8F93\u51FA\u7F16\u7801\u8868\u793A\u7684\u6574\u6570\u503C {0} \u7684\u5B57\u7B26\u3002"},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"\u65E0\u6CD5\u4E3A\u8F93\u51FA\u65B9\u6CD5 ''{1}'' \u52A0\u8F7D\u5C5E\u6027\u6587\u4EF6 ''{0}'' (\u68C0\u67E5 CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,38 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_zh_HK extends XMLErrorResources_zh_TW
{
}

View File

@@ -0,0 +1,452 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import java.util.ListResourceBundle;
/**
* Set up error messages.
* We build a two dimensional array of message keys and
* message strings. In order to add a new message here,
* you need to first add a String constant. And you need
* to enter key, value pair as part of the contents
* array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
*/
public class XMLErrorResources_zh_TW extends ListResourceBundle
{
/*
* This file contains error and warning messages related to Xalan Error
* Handling.
*
* General notes to translators:
*
* 1) Xalan (or more properly, Xalan-interpretive) and XSLTC are names of
* components.
* XSLT is an acronym for "XML Stylesheet Language: Transformations".
* XSLTC is an acronym for XSLT Compiler.
*
* 2) A stylesheet is a description of how to transform an input XML document
* into a resultant XML document (or HTML document or text). The
* stylesheet itself is described in the form of an XML document.
*
* 3) A template is a component of a stylesheet that is used to match a
* particular portion of an input document and specifies the form of the
* corresponding portion of the output document.
*
* 4) An element is a mark-up tag in an XML document; an attribute is a
* modifier on the tag. For example, in <elem attr='val' attr2='val2'>
* "elem" is an element name, "attr" and "attr2" are attribute names with
* the values "val" and "val2", respectively.
*
* 5) A namespace declaration is a special attribute that is used to associate
* a prefix with a URI (the namespace). The meanings of element names and
* attribute names that use that prefix are defined with respect to that
* namespace.
*
* 6) "Translet" is an invented term that describes the class file that
* results from compiling an XML stylesheet into a Java class.
*
* 7) XPath is a specification that describes a notation for identifying
* nodes in a tree-structured representation of an XML document. An
* instance of that notation is referred to as an XPath expression.
*
*/
/** Maximum error messages, this is needed to keep track of the number of messages. */
public static final int MAX_CODE = 61;
/** Maximum warnings, this is needed to keep track of the number of warnings. */
public static final int MAX_WARNING = 0;
/** Maximum misc strings. */
public static final int MAX_OTHERS = 4;
/** Maximum total warnings and error messages. */
public static final int MAX_MESSAGES = MAX_CODE + MAX_WARNING + 1;
/*
* Message keys
*/
public static final String ER_FUNCTION_NOT_SUPPORTED = "ER_FUNCTION_NOT_SUPPORTED";
public static final String ER_CANNOT_OVERWRITE_CAUSE = "ER_CANNOT_OVERWRITE_CAUSE";
public static final String ER_NO_DEFAULT_IMPL = "ER_NO_DEFAULT_IMPL";
public static final String ER_CHUNKEDINTARRAY_NOT_SUPPORTED = "ER_CHUNKEDINTARRAY_NOT_SUPPORTED";
public static final String ER_OFFSET_BIGGER_THAN_SLOT = "ER_OFFSET_BIGGER_THAN_SLOT";
public static final String ER_COROUTINE_NOT_AVAIL = "ER_COROUTINE_NOT_AVAIL";
public static final String ER_COROUTINE_CO_EXIT = "ER_COROUTINE_CO_EXIT";
public static final String ER_COJOINROUTINESET_FAILED = "ER_COJOINROUTINESET_FAILED";
public static final String ER_COROUTINE_PARAM = "ER_COROUTINE_PARAM";
public static final String ER_PARSER_DOTERMINATE_ANSWERS = "ER_PARSER_DOTERMINATE_ANSWERS";
public static final String ER_NO_PARSE_CALL_WHILE_PARSING = "ER_NO_PARSE_CALL_WHILE_PARSING";
public static final String ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_AXIS_NOT_IMPLEMENTED = "ER_ITERATOR_AXIS_NOT_IMPLEMENTED";
public static final String ER_ITERATOR_CLONE_NOT_SUPPORTED = "ER_ITERATOR_CLONE_NOT_SUPPORTED";
public static final String ER_UNKNOWN_AXIS_TYPE = "ER_UNKNOWN_AXIS_TYPE";
public static final String ER_AXIS_NOT_SUPPORTED = "ER_AXIS_NOT_SUPPORTED";
public static final String ER_NO_DTMIDS_AVAIL = "ER_NO_DTMIDS_AVAIL";
public static final String ER_NOT_SUPPORTED = "ER_NOT_SUPPORTED";
public static final String ER_NODE_NON_NULL = "ER_NODE_NON_NULL";
public static final String ER_COULD_NOT_RESOLVE_NODE = "ER_COULD_NOT_RESOLVE_NODE";
public static final String ER_STARTPARSE_WHILE_PARSING = "ER_STARTPARSE_WHILE_PARSING";
public static final String ER_STARTPARSE_NEEDS_SAXPARSER = "ER_STARTPARSE_NEEDS_SAXPARSER";
public static final String ER_COULD_NOT_INIT_PARSER = "ER_COULD_NOT_INIT_PARSER";
public static final String ER_EXCEPTION_CREATING_POOL = "ER_EXCEPTION_CREATING_POOL";
public static final String ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE = "ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE";
public static final String ER_SCHEME_REQUIRED = "ER_SCHEME_REQUIRED";
public static final String ER_NO_SCHEME_IN_URI = "ER_NO_SCHEME_IN_URI";
public static final String ER_NO_SCHEME_INURI = "ER_NO_SCHEME_INURI";
public static final String ER_PATH_INVALID_CHAR = "ER_PATH_INVALID_CHAR";
public static final String ER_SCHEME_FROM_NULL_STRING = "ER_SCHEME_FROM_NULL_STRING";
public static final String ER_SCHEME_NOT_CONFORMANT = "ER_SCHEME_NOT_CONFORMANT";
public static final String ER_HOST_ADDRESS_NOT_WELLFORMED = "ER_HOST_ADDRESS_NOT_WELLFORMED";
public static final String ER_PORT_WHEN_HOST_NULL = "ER_PORT_WHEN_HOST_NULL";
public static final String ER_INVALID_PORT = "ER_INVALID_PORT";
public static final String ER_FRAG_FOR_GENERIC_URI ="ER_FRAG_FOR_GENERIC_URI";
public static final String ER_FRAG_WHEN_PATH_NULL = "ER_FRAG_WHEN_PATH_NULL";
public static final String ER_FRAG_INVALID_CHAR = "ER_FRAG_INVALID_CHAR";
public static final String ER_PARSER_IN_USE = "ER_PARSER_IN_USE";
public static final String ER_CANNOT_CHANGE_WHILE_PARSING = "ER_CANNOT_CHANGE_WHILE_PARSING";
public static final String ER_SELF_CAUSATION_NOT_PERMITTED = "ER_SELF_CAUSATION_NOT_PERMITTED";
public static final String ER_NO_USERINFO_IF_NO_HOST = "ER_NO_USERINFO_IF_NO_HOST";
public static final String ER_NO_PORT_IF_NO_HOST = "ER_NO_PORT_IF_NO_HOST";
public static final String ER_NO_QUERY_STRING_IN_PATH = "ER_NO_QUERY_STRING_IN_PATH";
public static final String ER_NO_FRAGMENT_STRING_IN_PATH = "ER_NO_FRAGMENT_STRING_IN_PATH";
public static final String ER_CANNOT_INIT_URI_EMPTY_PARMS = "ER_CANNOT_INIT_URI_EMPTY_PARMS";
public static final String ER_METHOD_NOT_SUPPORTED ="ER_METHOD_NOT_SUPPORTED";
public static final String ER_INCRSAXSRCFILTER_NOT_RESTARTABLE = "ER_INCRSAXSRCFILTER_NOT_RESTARTABLE";
public static final String ER_XMLRDR_NOT_BEFORE_STARTPARSE = "ER_XMLRDR_NOT_BEFORE_STARTPARSE";
public static final String ER_AXIS_TRAVERSER_NOT_SUPPORTED = "ER_AXIS_TRAVERSER_NOT_SUPPORTED";
public static final String ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER = "ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER";
public static final String ER_SYSTEMID_UNKNOWN = "ER_SYSTEMID_UNKNOWN";
public static final String ER_LOCATION_UNKNOWN = "ER_LOCATION_UNKNOWN";
public static final String ER_PREFIX_MUST_RESOLVE = "ER_PREFIX_MUST_RESOLVE";
public static final String ER_CREATEDOCUMENT_NOT_SUPPORTED = "ER_CREATEDOCUMENT_NOT_SUPPORTED";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT";
public static final String ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT = "ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT";
public static final String ER_CANT_OUTPUT_TEXT_BEFORE_DOC = "ER_CANT_OUTPUT_TEXT_BEFORE_DOC";
public static final String ER_CANT_HAVE_MORE_THAN_ONE_ROOT = "ER_CANT_HAVE_MORE_THAN_ONE_ROOT";
public static final String ER_ARG_LOCALNAME_NULL = "ER_ARG_LOCALNAME_NULL";
public static final String ER_ARG_LOCALNAME_INVALID = "ER_ARG_LOCALNAME_INVALID";
public static final String ER_ARG_PREFIX_INVALID = "ER_ARG_PREFIX_INVALID";
public static final String ER_NAME_CANT_START_WITH_COLON = "ER_NAME_CANT_START_WITH_COLON";
// Message keys used by the serializer
public static final String ER_RESOURCE_COULD_NOT_FIND = "ER_RESOURCE_COULD_NOT_FIND";
public static final String ER_RESOURCE_COULD_NOT_LOAD = "ER_RESOURCE_COULD_NOT_LOAD";
public static final String ER_BUFFER_SIZE_LESSTHAN_ZERO = "ER_BUFFER_SIZE_LESSTHAN_ZERO";
public static final String ER_INVALID_UTF16_SURROGATE = "ER_INVALID_UTF16_SURROGATE";
public static final String ER_OIERROR = "ER_OIERROR";
public static final String ER_NAMESPACE_PREFIX = "ER_NAMESPACE_PREFIX";
public static final String ER_STRAY_ATTRIBUTE = "ER_STRAY_ATTIRBUTE";
public static final String ER_STRAY_NAMESPACE = "ER_STRAY_NAMESPACE";
public static final String ER_COULD_NOT_LOAD_RESOURCE = "ER_COULD_NOT_LOAD_RESOURCE";
public static final String ER_COULD_NOT_LOAD_METHOD_PROPERTY = "ER_COULD_NOT_LOAD_METHOD_PROPERTY";
public static final String ER_SERIALIZER_NOT_CONTENTHANDLER = "ER_SERIALIZER_NOT_CONTENTHANDLER";
public static final String ER_ILLEGAL_ATTRIBUTE_POSITION = "ER_ILLEGAL_ATTRIBUTE_POSITION";
public static final String ER_ILLEGAL_CHARACTER = "ER_ILLEGAL_CHARACTER";
/*
* Now fill in the message text.
* Then fill in the message text for that message code in the
* array. Use the new error code as the index into the array.
*/
// Error messages...
/** The lookup table for error messages. */
private static final Object[][] contents = {
/** Error message ID that has a null message, but takes in a single object. */
{"ER0000" , "{0}" },
{ ER_FUNCTION_NOT_SUPPORTED,
"\u4E0D\u652F\u63F4\u51FD\u6578\uFF01"},
{ ER_CANNOT_OVERWRITE_CAUSE,
"\u7121\u6CD5\u8986\u5BEB\u539F\u56E0"},
{ ER_NO_DEFAULT_IMPL,
"\u627E\u4E0D\u5230\u9810\u8A2D\u7684\u5BE6\u884C"},
{ ER_CHUNKEDINTARRAY_NOT_SUPPORTED,
"\u76EE\u524D\u4E0D\u652F\u63F4 ChunkedIntArray({0})"},
{ ER_OFFSET_BIGGER_THAN_SLOT,
"\u4F4D\u79FB\u5927\u65BC\u4F4D\u7F6E"},
{ ER_COROUTINE_NOT_AVAIL,
"\u6C92\u6709\u53EF\u7528\u7684\u5171\u540C\u5E38\u5F0F\uFF0Cid={0}"},
{ ER_COROUTINE_CO_EXIT,
"CoroutineManager \u6536\u5230 co_exit() \u8981\u6C42"},
{ ER_COJOINROUTINESET_FAILED,
"co_joinCoroutineSet() \u5931\u6557"},
{ ER_COROUTINE_PARAM,
"\u5171\u540C\u5E38\u5F0F\u53C3\u6578\u932F\u8AA4 ({0})"},
{ ER_PARSER_DOTERMINATE_ANSWERS,
"\n\u672A\u9810\u671F: \u5256\u6790\u5668 doTerminate \u7B54\u8986 {0}"},
{ ER_NO_PARSE_CALL_WHILE_PARSING,
"\u5256\u6790\u6642\u53EF\u80FD\u672A\u547C\u53EB parse"},
{ ER_TYPED_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\u932F\u8AA4: \u672A\u5BE6\u884C\u8EF8 {0} \u7684\u985E\u578B\u91CD\u8907\u7A0B\u5F0F"},
{ ER_ITERATOR_AXIS_NOT_IMPLEMENTED,
"\u932F\u8AA4: \u672A\u5BE6\u884C\u8EF8 {0} \u7684\u91CD\u8907\u7A0B\u5F0F"},
{ ER_ITERATOR_CLONE_NOT_SUPPORTED,
"\u4E0D\u652F\u63F4\u91CD\u8907\u7A0B\u5F0F\u8907\u88FD"},
{ ER_UNKNOWN_AXIS_TYPE,
"\u4E0D\u660E\u7684\u8EF8\u5468\u904A\u985E\u578B: {0}"},
{ ER_AXIS_NOT_SUPPORTED,
"\u4E0D\u652F\u63F4\u8EF8\u5468\u904A\u7A0B\u5F0F: {0}"},
{ ER_NO_DTMIDS_AVAIL,
"\u4E0D\u518D\u6709\u53EF\u7528\u7684 DTM ID"},
{ ER_NOT_SUPPORTED,
"\u4E0D\u652F\u63F4: {0}"},
{ ER_NODE_NON_NULL,
"\u7BC0\u9EDE\u5FC5\u9808\u662F\u975E\u7A7A\u503C\u7684 getDTMHandleFromNode"},
{ ER_COULD_NOT_RESOLVE_NODE,
"\u7121\u6CD5\u89E3\u6790\u7BC0\u9EDE\u70BA\u63A7\u5236\u4EE3\u78BC"},
{ ER_STARTPARSE_WHILE_PARSING,
"\u5256\u6790\u6642\u53EF\u80FD\u672A\u547C\u53EB startParse"},
{ ER_STARTPARSE_NEEDS_SAXPARSER,
"startParse \u9700\u8981\u975E\u7A7A\u503C SAXParser"},
{ ER_COULD_NOT_INIT_PARSER,
"\u7121\u6CD5\u8D77\u59CB\u5256\u6790\u5668"},
{ ER_EXCEPTION_CREATING_POOL,
"\u5EFA\u7ACB\u96C6\u5340\u7684\u65B0\u57F7\u884C\u8655\u7406\u6642\u767C\u751F\u7570\u5E38\u72C0\u6CC1"},
{ ER_PATH_CONTAINS_INVALID_ESCAPE_SEQUENCE,
"\u8DEF\u5F91\u5305\u542B\u7121\u6548\u7684\u9041\u96E2\u5E8F\u5217"},
{ ER_SCHEME_REQUIRED,
"\u914D\u7F6E\u662F\u5FC5\u8981\u7684\uFF01"},
{ ER_NO_SCHEME_IN_URI,
"\u5728 URI \u4E2D\u627E\u4E0D\u5230\u914D\u7F6E: {0}"},
{ ER_NO_SCHEME_INURI,
"\u5728 URI \u627E\u4E0D\u5230\u914D\u7F6E"},
{ ER_PATH_INVALID_CHAR,
"\u8DEF\u5F91\u5305\u542B\u7121\u6548\u7684\u5B57\u5143: {0}"},
{ ER_SCHEME_FROM_NULL_STRING,
"\u7121\u6CD5\u5F9E\u7A7A\u503C\u5B57\u4E32\u8A2D\u5B9A\u914D\u7F6E"},
{ ER_SCHEME_NOT_CONFORMANT,
"\u914D\u7F6E\u4E0D\u4E00\u81F4\u3002"},
{ ER_HOST_ADDRESS_NOT_WELLFORMED,
"\u4E3B\u6A5F\u6C92\u6709\u5B8C\u6574\u7684\u4F4D\u5740"},
{ ER_PORT_WHEN_HOST_NULL,
"\u4E3B\u6A5F\u70BA\u7A7A\u503C\u6642\uFF0C\u7121\u6CD5\u8A2D\u5B9A\u9023\u63A5\u57E0"},
{ ER_INVALID_PORT,
"\u7121\u6548\u7684\u9023\u63A5\u57E0\u865F\u78BC"},
{ ER_FRAG_FOR_GENERIC_URI,
"\u53EA\u80FD\u5C0D\u4E00\u822C URI \u8A2D\u5B9A\u7247\u6BB5"},
{ ER_FRAG_WHEN_PATH_NULL,
"\u8DEF\u5F91\u70BA\u7A7A\u503C\u6642\uFF0C\u7121\u6CD5\u8A2D\u5B9A\u7247\u6BB5"},
{ ER_FRAG_INVALID_CHAR,
"\u7247\u6BB5\u5305\u542B\u7121\u6548\u7684\u5B57\u5143"},
{ ER_PARSER_IN_USE,
"\u5256\u6790\u5668\u4F7F\u7528\u4E2D"},
{ ER_CANNOT_CHANGE_WHILE_PARSING,
"\u5256\u6790\u6642\u7121\u6CD5\u8B8A\u66F4 {0} {1}"},
{ ER_SELF_CAUSATION_NOT_PERMITTED,
"\u4E0D\u5141\u8A31\u81EA\u884C\u5F15\u767C"},
{ ER_NO_USERINFO_IF_NO_HOST,
"\u5982\u679C\u6C92\u6709\u6307\u5B9A\u4E3B\u6A5F\uFF0C\u4E0D\u53EF\u6307\u5B9A Userinfo"},
{ ER_NO_PORT_IF_NO_HOST,
"\u5982\u679C\u6C92\u6709\u6307\u5B9A\u4E3B\u6A5F\uFF0C\u4E0D\u53EF\u6307\u5B9A\u9023\u63A5\u57E0"},
{ ER_NO_QUERY_STRING_IN_PATH,
"\u5728\u8DEF\u5F91\u53CA\u67E5\u8A62\u5B57\u4E32\u4E2D\u4E0D\u53EF\u6307\u5B9A\u67E5\u8A62\u5B57\u4E32"},
{ ER_NO_FRAGMENT_STRING_IN_PATH,
"\u8DEF\u5F91\u548C\u7247\u6BB5\u4E0D\u80FD\u540C\u6642\u6307\u5B9A\u7247\u6BB5"},
{ ER_CANNOT_INIT_URI_EMPTY_PARMS,
"\u7121\u6CD5\u4EE5\u7A7A\u767D\u53C3\u6578\u8D77\u59CB\u8A2D\u5B9A URI"},
{ ER_METHOD_NOT_SUPPORTED,
"\u5C1A\u4E0D\u652F\u63F4\u65B9\u6CD5"},
{ ER_INCRSAXSRCFILTER_NOT_RESTARTABLE,
"IncrementalSAXSource_Filter \u76EE\u524D\u7121\u6CD5\u91CD\u65B0\u555F\u52D5"},
{ ER_XMLRDR_NOT_BEFORE_STARTPARSE,
"XMLReader \u4E0D\u80FD\u5728 startParse \u8981\u6C42\u4E4B\u524D"},
{ ER_AXIS_TRAVERSER_NOT_SUPPORTED,
"\u4E0D\u652F\u63F4\u8EF8\u5468\u904A\u7A0B\u5F0F: {0}"},
{ ER_ERRORHANDLER_CREATED_WITH_NULL_PRINTWRITER,
"\u4F7F\u7528\u7A7A\u503C PrintWriter \u5EFA\u7ACB ListingErrorHandler\uFF01"},
{ ER_SYSTEMID_UNKNOWN,
"\u4E0D\u660E\u7684 SystemId"},
{ ER_LOCATION_UNKNOWN,
"\u4E0D\u660E\u7684\u932F\u8AA4\u4F4D\u7F6E"},
{ ER_PREFIX_MUST_RESOLVE,
"\u524D\u7F6E\u78BC\u5FC5\u9808\u89E3\u6790\u70BA\u547D\u540D\u7A7A\u9593: {0}"},
{ ER_CREATEDOCUMENT_NOT_SUPPORTED,
"XPathContext \u4E2D\u4E0D\u652F\u63F4 createDocument()\uFF01"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT,
"\u5C6C\u6027\u5B50\u9805\u4E0D\u5177\u6709\u64C1\u6709\u8005\u6587\u4EF6\uFF01"},
{ ER_CHILD_HAS_NO_OWNER_DOCUMENT_ELEMENT,
"\u5C6C\u6027\u5B50\u9805\u4E0D\u5177\u6709\u64C1\u6709\u8005\u6587\u4EF6\u5143\u7D20\uFF01"},
{ ER_CANT_OUTPUT_TEXT_BEFORE_DOC,
"\u8B66\u544A: \u7121\u6CD5\u5728\u6587\u4EF6\u5143\u7D20\u4E4B\u524D\u8F38\u51FA\u6587\u5B57\uFF01\u6B63\u5728\u5FFD\u7565..."},
{ ER_CANT_HAVE_MORE_THAN_ONE_ROOT,
"DOM \u7684\u6839\u4E0D\u80FD\u8D85\u904E\u4E00\u500B\uFF01"},
{ ER_ARG_LOCALNAME_NULL,
"\u5F15\u6578 'localName' \u70BA\u7A7A\u503C"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The localname is the portion after the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_LOCALNAME_INVALID,
"QNAME \u4E2D\u7684 Localname \u61C9\u70BA\u6709\u6548\u7684 NCName"},
// Note to translators: A QNAME has the syntactic form [NCName:]NCName
// The prefix is the portion before the optional colon; the message indicates
// that there is a problem with that part of the QNAME.
{ ER_ARG_PREFIX_INVALID,
"QNAME \u4E2D\u7684\u524D\u7F6E\u78BC\u61C9\u70BA\u6709\u6548\u7684 NCName"},
{ ER_NAME_CANT_START_WITH_COLON,
"\u540D\u7A31\u4E0D\u80FD\u4EE5\u5192\u865F\u70BA\u958B\u982D"},
{ "BAD_CODE", "createMessage \u7684\u53C3\u6578\u8D85\u51FA\u7BC4\u570D"},
{ "FORMAT_FAILED", "messageFormat \u547C\u53EB\u671F\u9593\u767C\u751F\u7570\u5E38\u72C0\u6CC1"},
{ "line", "\u884C\u865F"},
{ "column","\u8CC7\u6599\u6B04\u7DE8\u865F"},
{ER_SERIALIZER_NOT_CONTENTHANDLER,
"serializer \u985E\u5225 ''{0}'' \u4E0D\u5BE6\u884C org.xml.sax.ContentHandler\u3002"},
{ER_RESOURCE_COULD_NOT_FIND,
"\u627E\u4E0D\u5230\u8CC7\u6E90 [ {0} ]\u3002\n{1}" },
{ER_RESOURCE_COULD_NOT_LOAD,
"\u7121\u6CD5\u8F09\u5165\u8CC7\u6E90 [ {0} ]: {1} \n {2} \t {3}" },
{ER_BUFFER_SIZE_LESSTHAN_ZERO,
"\u7DE9\u885D\u5340\u5927\u5C0F <=0" },
{ER_INVALID_UTF16_SURROGATE,
"\u5075\u6E2C\u5230\u7121\u6548\u7684 UTF-16 \u4EE3\u7406: {0}\uFF1F" },
{ER_OIERROR,
"IO \u932F\u8AA4" },
{ER_ILLEGAL_ATTRIBUTE_POSITION,
"\u5728\u7522\u751F\u5B50\u9805\u7BC0\u9EDE\u4E4B\u5F8C\uFF0C\u6216\u5728\u7522\u751F\u5143\u7D20\u4E4B\u524D\uFF0C\u4E0D\u53EF\u65B0\u589E\u5C6C\u6027 {0}\u3002\u5C6C\u6027\u6703\u88AB\u5FFD\u7565\u3002"},
/*
* Note to translators: The stylesheet contained a reference to a
* namespace prefix that was undefined. The value of the substitution
* text is the name of the prefix.
*/
{ER_NAMESPACE_PREFIX,
"\u5B57\u9996 ''{0}'' \u7684\u547D\u540D\u7A7A\u9593\u5C1A\u672A\u5BA3\u544A\u3002" },
/*
* Note to translators: This message is reported if the stylesheet
* being processed attempted to construct an XML document with an
* attribute in a place other than on an element. The substitution text
* specifies the name of the attribute.
*/
{ER_STRAY_ATTRIBUTE,
"\u5C6C\u6027 ''{0}'' \u5728\u5143\u7D20\u4E4B\u5916\u3002" },
/*
* Note to translators: As with the preceding message, a namespace
* declaration has the form of an attribute and is only permitted to
* appear on an element. The substitution text {0} is the namespace
* prefix and {1} is the URI that was being used in the erroneous
* namespace declaration.
*/
{ER_STRAY_NAMESPACE,
"\u547D\u540D\u7A7A\u9593\u5BA3\u544A ''{0}''=''{1}'' \u8D85\u51FA\u5143\u7D20\u5916\u3002" },
{ER_COULD_NOT_LOAD_RESOURCE,
"\u7121\u6CD5\u8F09\u5165 ''{0}'' (\u6AA2\u67E5 CLASSPATH)\uFF0C\u76EE\u524D\u53EA\u4F7F\u7528\u9810\u8A2D\u503C"},
{ ER_ILLEGAL_CHARACTER,
"\u5617\u8A66\u8F38\u51FA\u6574\u6578\u503C {0} \u7684\u5B57\u5143\uFF0C\u4F46\u662F\u5B83\u4E0D\u662F\u4EE5\u6307\u5B9A\u7684 {1} \u8F38\u51FA\u7DE8\u78BC\u5448\u73FE\u3002"},
{ER_COULD_NOT_LOAD_METHOD_PROPERTY,
"\u7121\u6CD5\u8F09\u5165\u8F38\u51FA\u65B9\u6CD5 ''{1}'' \u7684\u5C6C\u6027\u6A94 ''{0}'' (\u6AA2\u67E5 CLASSPATH)" }
};
/**
* Get the association list.
*
* @return The association list.
*/
protected Object[][] getContents() {
return contents;
}
}

View File

@@ -0,0 +1,158 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.res;
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
import java.util.ListResourceBundle;
import java.util.Locale;
/**
* A utility class for issuing XML error messages.
* @xsl.usage internal
*/
public class XMLMessages
{
/** The local object to use. */
protected Locale fLocale = Locale.getDefault();
/** The language specific resource object for XML messages. */
private static ListResourceBundle XMLBundle = null;
/** The class name of the XML error message string table. */
private static final String XML_ERROR_RESOURCES =
"com.sun.org.apache.xml.internal.res.XMLErrorResources";
/** String to use if a bad message code is used. */
protected static final String BAD_CODE = "BAD_CODE";
/** String to use if the message format operation failed. */
protected static final String FORMAT_FAILED = "FORMAT_FAILED";
/**
* Set the Locale object to use.
*
* @param locale non-null reference to Locale object.
*/
public void setLocale(Locale locale)
{
fLocale = locale;
}
/**
* Get the Locale object that is being used.
*
* @return non-null reference to Locale object.
*/
public Locale getLocale()
{
return fLocale;
}
/**
* Creates a message from the specified key and replacement
* arguments, localized to the given locale.
*
* @param msgKey The key for the message text.
* @param args The arguments to be used as replacement text
* in the message created.
*
* @return The formatted message string.
*/
public static final String createXMLMessage(String msgKey, Object args[])
{
if (XMLBundle == null) {
XMLBundle = SecuritySupport.getResourceBundle(XML_ERROR_RESOURCES);
}
if (XMLBundle != null)
{
return createMsg(XMLBundle, msgKey, args);
}
else
return "Could not load any resource bundles.";
}
/**
* Creates a message from the specified key and replacement
* arguments, localized to the given locale.
*
* @param fResourceBundle The resource bundle to use.
* @param msgKey The message key to use.
* @param args The arguments to be used as replacement text
* in the message created.
*
* @return The formatted message string.
*/
public static final String createMsg(ListResourceBundle fResourceBundle,
String msgKey, Object args[]) //throws Exception
{
String fmsg = null;
boolean throwex = false;
String msg = null;
if (msgKey != null)
msg = fResourceBundle.getString(msgKey);
if (msg == null)
{
msg = fResourceBundle.getString(BAD_CODE);
throwex = true;
}
if (args != null)
{
try
{
// Do this to keep format from crying.
// This is better than making a bunch of conditional
// code all over the place.
int n = args.length;
for (int i = 0; i < n; i++)
{
if (null == args[i])
args[i] = "";
}
fmsg = java.text.MessageFormat.format(msg, args);
}
catch (Exception e)
{
fmsg = fResourceBundle.getString(FORMAT_FAILED);
fmsg += " " + msg;
}
}
else
fmsg = msg;
if (throwex)
{
throw new RuntimeException(fmsg);
}
return fmsg;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,251 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// CatalogEntry.java - Represents Catalog entries
package com.sun.org.apache.xml.internal.resolver;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Represents a Catalog entry.
*
* <p>Instances of this class represent individual entries
* in a Catalog.</p>
*
* <p>Each catalog entry has a unique name and is associated with
* an arbitrary number of arguments (all strings). For example, the
* TR9401 catalog entry "PUBLIC" has two arguments, a public identifier
* and a system identifier. Each entry has a unique numeric type,
* assigned automatically when the entry type is created.</p>
*
* <p>The number and type of catalog entries is maintained
* <em>statically</em>. Catalog classes, or their subclasses, can add
* new entry types, but all Catalog objects share the same global pool
* of types.</p>
*
* <p>Initially there are no valid entries.</p>
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class CatalogEntry {
/** The nextEntry is the ordinal number of the next entry type. */
protected static AtomicInteger nextEntry = new AtomicInteger(0);
/**
* The entryTypes vector maps catalog entry names
* (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.).
* Names are case sensitive.
*/
protected static final Map<String, Integer> entryTypes = new ConcurrentHashMap<>();
/** The entryTypes vector maps catalog entry types to the
number of arguments they're required to have. */
protected static Vector entryArgs = new Vector();
/**
* Adds a new catalog entry type.
*
* @param name The name of the catalog entry type. This must be
* unique among all types and is case-sensitive. (Adding a duplicate
* name effectively replaces the old type with the new type.)
* @param numArgs The number of arguments that this entry type
* is required to have. There is no provision for variable numbers
* of arguments.
* @return The type for the new entry.
*/
static int addEntryType(String name, int numArgs) {
final int index = nextEntry.getAndIncrement();
entryTypes.put(name, index);
entryArgs.add(index, numArgs);
return index;
}
/**
* Lookup an entry type
*
* @param name The name of the catalog entry type.
* @return The type of the catalog entry with the specified name.
* @throws InvalidCatalogEntryTypeException if no entry has the
* specified name.
*/
public static int getEntryType(String name)
throws CatalogException {
if (!entryTypes.containsKey(name)) {
throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
}
Integer iType = entryTypes.get(name);
if (iType == null) {
throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
}
return iType;
}
/**
* Find out how many arguments an entry is required to have.
*
* @param name The name of the catalog entry type.
* @return The number of arguments that entry type is required to have.
* @throws InvalidCatalogEntryTypeException if no entry has the
* specified name.
*/
public static int getEntryArgCount(String name)
throws CatalogException {
return getEntryArgCount(getEntryType(name));
}
/**
* Find out how many arguments an entry is required to have.
*
* @param type A valid catalog entry type.
* @return The number of arguments that entry type is required to have.
* @throws InvalidCatalogEntryTypeException if the type is invalid.
*/
public static int getEntryArgCount(int type)
throws CatalogException {
try {
Integer iArgs = (Integer) entryArgs.get(type);
return iArgs.intValue();
} catch (ArrayIndexOutOfBoundsException e) {
throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
}
}
/** The entry type of this entry */
protected int entryType = 0;
/** The arguments associated with this entry */
protected Vector args = null;
/**
* Null constructor; something for subclasses to call.
*/
public CatalogEntry() {}
/**
* Construct a catalog entry of the specified type.
*
* @param name The name of the entry type
* @param args A String Vector of arguments
* @throws InvalidCatalogEntryTypeException if no such entry type
* exists.
* @throws InvalidCatalogEntryException if the wrong number of arguments
* is passed.
*/
public CatalogEntry(String name, Vector args)
throws CatalogException {
Integer iType = entryTypes.get(name);
if (iType == null) {
throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
}
int type = iType;
try {
Integer iArgs = (Integer) entryArgs.get(type);
if (iArgs.intValue() != args.size()) {
throw new CatalogException(CatalogException.INVALID_ENTRY);
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
}
entryType = type;
this.args = args;
}
/**
* Construct a catalog entry of the specified type.
*
* @param type The entry type
* @param args A String Vector of arguments
* @throws InvalidCatalogEntryTypeException if no such entry type
* exists.
* @throws InvalidCatalogEntryException if the wrong number of arguments
* is passed.
*/
public CatalogEntry(int type, Vector args)
throws CatalogException {
try {
Integer iArgs = (Integer) entryArgs.get(type);
if (iArgs.intValue() != args.size()) {
throw new CatalogException(CatalogException.INVALID_ENTRY);
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE);
}
entryType = type;
this.args = args;
}
/**
* Get the entry type.
*
* @return The entry type of the CatalogEntry
*/
public int getEntryType() {
return entryType;
}
/**
* Get an entry argument.
*
* @param argNum The argument number (arguments are numbered from 0).
* @return The specified argument or null if an invalid argNum is
* provided.
*/
public String getEntryArg(int argNum) {
try {
String arg = (String) args.get(argNum);
return arg;
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
}
/**
* Set an entry argument.
*
* <p>Catalogs sometimes need to adjust the catlog entry parameters,
* for example to make a relative URI absolute with respect to the
* current base URI. But in general, this function should only be
* called shortly after object creation to do some sort of cleanup.
* Catalog entries should not mutate over time.</p>
*
* @param argNum The argument number (arguments are numbered from 0).
* @throws ArrayIndexOutOfBoundsException if an invalid argument
* number is provided.
*/
public void setEntryArg(int argNum, String newspec)
throws ArrayIndexOutOfBoundsException {
args.set(argNum, newspec);
}
}

View File

@@ -0,0 +1,168 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// CatalogException.java - Catalog exception
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver;
/**
* Signal Catalog exception.
*
* <p>This exception is thrown if an error occurs loading a
* catalog file.</p>
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class CatalogException extends Exception {
/** A wrapper around another exception */
public static final int WRAPPER = 1;
/** An invalid entry */
public static final int INVALID_ENTRY = 2;
/** An invalid entry type */
public static final int INVALID_ENTRY_TYPE = 3;
/** Could not instantiate an XML parser */
public static final int NO_XML_PARSER = 4;
/** Unknown XML format */
public static final int UNKNOWN_FORMAT = 5;
/** Unparseable XML catalog (not XML)*/
public static final int UNPARSEABLE = 6;
/** XML but parse failed */
public static final int PARSE_FAILED = 7;
/** Text catalog ended in mid-comment */
public static final int UNENDED_COMMENT = 8;
/**
* The embedded exception if tunnelling, or null.
*/
private Exception exception = null;
private int exceptionType = 0;
/**
* Create a new CatalogException.
*
* @param type The exception type
* @param message The error or warning message.
*/
public CatalogException (int type, String message) {
super(message);
this.exceptionType = type;
this.exception = null;
}
/**
* Create a new CatalogException.
*
* @param type The exception type
*/
public CatalogException (int type) {
super("Catalog Exception " + type);
this.exceptionType = type;
this.exception = null;
}
/**
* Create a new CatalogException wrapping an existing exception.
*
* <p>The existing exception will be embedded in the new
* one, and its message will become the default message for
* the CatalogException.</p>
*
* @param e The exception to be wrapped in a CatalogException.
*/
public CatalogException (Exception e) {
super();
this.exceptionType = WRAPPER;
this.exception = e;
}
/**
* Create a new CatalogException from an existing exception.
*
* <p>The existing exception will be embedded in the new
* one, but the new exception will have its own message.</p>
*
* @param message The detail message.
* @param e The exception to be wrapped in a CatalogException.
*/
public CatalogException (String message, Exception e) {
super(message);
this.exceptionType = WRAPPER;
this.exception = e;
}
/**
* Return a detail message for this exception.
*
* <p>If there is an embedded exception, and if the CatalogException
* has no detail message of its own, this method will return
* the detail message from the embedded exception.</p>
*
* @return The error or warning message.
*/
public String getMessage ()
{
String message = super.getMessage();
if (message == null && exception != null) {
return exception.getMessage();
} else {
return message;
}
}
/**
* Return the embedded exception, if any.
*
* @return The embedded exception, or null if there is none.
*/
public Exception getException ()
{
return exception;
}
/**
* Return the exception type
*
* @return The exception type
*/
public int getExceptionType ()
{
return exceptionType;
}
/**
* Override toString to pick up any embedded exception.
*
* @return A string representation of this exception.
*/
public String toString ()
{
if (exception != null) {
return exception.toString();
} else {
return super.toString();
}
}
}

View File

@@ -0,0 +1,849 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// CatalogManager.java - Access CatalogManager.properties
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import com.sun.org.apache.xml.internal.resolver.helpers.BootstrapResolver;
import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.util.Vector;
import sun.reflect.misc.ReflectUtil;
/**
* CatalogManager provides an interface to the catalog properties.
*
* <p>Properties can come from two places: from system properties or
* from a <i>CatalogManager.properties</i> file. This class provides a transparent
* interface to both, with system properties preferred over property file values.</p>
*
* <p>The following table summarizes the properties:</p>
*
* <table border="1">
* <thead>
* <tr>
* <td>System Property</td>
* <td>CatalogManager.properties<br/>Property</td>
* <td>Description</td>
* </tr>
* </thead>
* <tbody>
* <tr>
* <td>xml.catalog.ignoreMissing</td>
* <td>&#160;</td>
* <td>If true, a missing <i>CatalogManager.properties</i> file or missing properties
* within that file will not generate warning messages. See also the
* <i>ignoreMissingProperties</i> method.</td>
* </tr>
*
* <tr>
* <td>xml.catalog.files</td>
* <td>catalogs</td>
* <td>The <emph>semicolon-delimited</emph> list of catalog files.</td>
* </tr>
*
* <tr>
* <td>&#160;</td>
* <td>relative-catalogs</td>
* <td>If false, relative catalog URIs are made absolute with respect to the base URI of
* the <i>CatalogManager.properties</i> file. This setting only applies to catalog
* URIs obtained from the <i>catalogs</i> property <emph>in the</emph>
* <i>CatalogManager.properties</i> file</td>
* </tr>
*
* <tr>
* <td>xml.catalog.verbosity</td>
* <td>verbosity</td>
* <td>If non-zero, the Catalog classes will print informative and debugging messages.
* The higher the number, the more messages.</td>
* </tr>
*
* <tr>
* <td>xml.catalog.prefer</td>
* <td>prefer</td>
* <td>Which identifier is preferred, "public" or "system"?</td>
* </tr>
*
* <tr>
* <td>xml.catalog.staticCatalog</td>
* <td>static-catalog</td>
* <td>Should a single catalog be constructed for all parsing, or should a different
* catalog be created for each parser?</td>
* </tr>
*
* <tr>
* <td>xml.catalog.allowPI</td>
* <td>allow-oasis-xml-catalog-pi</td>
* <td>If the source document contains "oasis-xml-catalog" processing instructions,
* should they be used?</td>
* </tr>
*
* <tr>
* <td>xml.catalog.className</td>
* <td>catalog-class-name</td>
* <td>If you're using the convenience classes
* <tt>com.sun.org.apache.xml.internal.resolver.tools.*</tt>), this setting
* allows you to specify an alternate class name to use for the underlying
* catalog.</td>
* </tr>
* </tbody>
* </table>
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public class CatalogManager {
private static String pFiles = "xml.catalog.files";
private static String pVerbosity = "xml.catalog.verbosity";
private static String pPrefer = "xml.catalog.prefer";
private static String pStatic = "xml.catalog.staticCatalog";
private static String pAllowPI = "xml.catalog.allowPI";
private static String pClassname = "xml.catalog.className";
private static String pIgnoreMissing = "xml.catalog.ignoreMissing";
/** A static CatalogManager instance for sharing */
private static CatalogManager staticManager = new CatalogManager();
/** The bootstrap resolver to use when loading XML Catalogs. */
private BootstrapResolver bResolver = new BootstrapResolver();
/** Flag to ignore missing property files and/or properties */
private boolean ignoreMissingProperties
= (SecuritySupport.getSystemProperty(pIgnoreMissing) != null
|| SecuritySupport.getSystemProperty(pFiles) != null);
/** Holds the resources after they are loaded from the file. */
private ResourceBundle resources;
/** The name of the CatalogManager properties file. */
private String propertyFile = "CatalogManager.properties";
/** The location of the propertyFile */
private URL propertyFileURI = null;
/** Default catalog files list. */
private String defaultCatalogFiles = "./xcatalog";
/** Current catalog files list. */
private String catalogFiles = null;
/** Did the catalogFiles come from the properties file? */
private boolean fromPropertiesFile = false;
/** Default verbosity level if there is no property setting for it. */
private int defaultVerbosity = 1;
/** Current verbosity level. */
private Integer verbosity = null;
/** Default preference setting. */
private boolean defaultPreferPublic = true;
/** Current preference setting. */
private Boolean preferPublic = null;
/** Default setting of the static catalog flag. */
private boolean defaultUseStaticCatalog = true;
/** Current setting of the static catalog flag. */
private Boolean useStaticCatalog = null;
/** The static catalog used by this manager. */
private static Catalog staticCatalog = null;
/** Default setting of the oasisXMLCatalogPI flag. */
private boolean defaultOasisXMLCatalogPI = true;
/** Current setting of the oasisXMLCatalogPI flag. */
private Boolean oasisXMLCatalogPI = null;
/** Default setting of the relativeCatalogs flag. */
private boolean defaultRelativeCatalogs = true;
/** Current setting of the relativeCatalogs flag. */
private Boolean relativeCatalogs = null;
/** Current catalog class name. */
private String catalogClassName = null;
/**
* Indicates whether implementation parts should use
* service loader (or similar).
* Note the default value (false) is the safe option..
*/
private boolean overrideDefaultParser;
/** The manager's debug object. Used for printing debugging messages.
*
* <p>This field is public so that objects that have access to this
* CatalogManager can use this debug object.</p>
*/
public Debug debug = null;
/** Constructor. */
public CatalogManager() {
init();
}
/** Constructor that specifies an explicit property file. */
public CatalogManager(String propertyFile) {
this.propertyFile = propertyFile;
init();
}
private void init() {
debug = new Debug();
// Note that we don't setDebug() here; we do that lazily. Either the
// user will set it explicitly, or we'll do it automagically if they
// read from the propertyFile for some other reason. That way, there's
// no attempt to read from the file before the caller has had a chance
// to avoid it.
if (System.getSecurityManager() == null) {
overrideDefaultParser = true;
}
}
/** Set the bootstrap resolver.*/
public void setBootstrapResolver(BootstrapResolver resolver) {
bResolver = resolver;
}
/** Get the bootstrap resolver.*/
public BootstrapResolver getBootstrapResolver() {
return bResolver;
}
/**
* Load the properties from the propertyFile and build the
* resources from it.
*/
private synchronized void readProperties() {
try {
propertyFileURI = CatalogManager.class.getResource("/"+propertyFile);
InputStream in =
CatalogManager.class.getResourceAsStream("/"+propertyFile);
if (in==null) {
if (!ignoreMissingProperties) {
System.err.println("Cannot find "+propertyFile);
// there's no reason to give this warning more than once
ignoreMissingProperties = true;
}
return;
}
resources = new PropertyResourceBundle(in);
} catch (MissingResourceException mre) {
if (!ignoreMissingProperties) {
System.err.println("Cannot read "+propertyFile);
}
} catch (java.io.IOException e) {
if (!ignoreMissingProperties) {
System.err.println("Failure trying to read "+propertyFile);
}
}
// This is a bit of a hack. After we've successfully read the properties,
// use them to set the default debug level, if the user hasn't already set
// the default debug level.
if (verbosity == null) {
try {
String verbStr = resources.getString("verbosity");
int verb = Integer.parseInt(verbStr.trim());
debug.setDebug(verb);
verbosity = new Integer(verb);
} catch (Exception e) {
// nop
}
}
}
/**
* Allow access to the static CatalogManager
*/
public static CatalogManager getStaticManager() {
return staticManager;
}
/**
* How are missing properties handled?
*
* <p>If true, missing or unreadable property files will
* not be reported. Otherwise, a message will be sent to System.err.
* </p>
*/
public boolean getIgnoreMissingProperties() {
return ignoreMissingProperties;
}
/**
* How should missing properties be handled?
*
* <p>If ignore is true, missing or unreadable property files will
* not be reported. Otherwise, a message will be sent to System.err.
* </p>
*/
public void setIgnoreMissingProperties(boolean ignore) {
ignoreMissingProperties = ignore;
}
/**
* How are missing properties handled?
*
* <p>If ignore is true, missing or unreadable property files will
* not be reported. Otherwise, a message will be sent to System.err.
* </p>
*
* @deprecated No longer static; use get/set methods.
*/
public void ignoreMissingProperties(boolean ignore) {
setIgnoreMissingProperties(ignore);
}
/**
* Obtain the verbosity setting from the properties.
*
* @return The verbosity level from the propertyFile or the
* defaultVerbosity.
*/
private int queryVerbosity () {
String defaultVerbStr = Integer.toString(defaultVerbosity);
String verbStr = SecuritySupport.getSystemProperty(pVerbosity);
if (verbStr == null) {
if (resources==null) readProperties();
if (resources != null) {
try {
verbStr = resources.getString("verbosity");
} catch (MissingResourceException e) {
verbStr = defaultVerbStr;
}
} else {
verbStr = defaultVerbStr;
}
}
int verb = defaultVerbosity;
try {
verb = Integer.parseInt(verbStr.trim());
} catch (Exception e) {
System.err.println("Cannot parse verbosity: \"" + verbStr + "\"");
}
// This is a bit of a hack. After we've successfully got the verbosity,
// we have to use it to set the default debug level,
// if the user hasn't already set the default debug level.
if (verbosity == null) {
debug.setDebug(verb);
verbosity = new Integer(verb);
}
return verb;
}
/**
* What is the current verbosity?
*/
public int getVerbosity() {
if (verbosity == null) {
verbosity = new Integer(queryVerbosity());
}
return verbosity.intValue();
}
/**
* Set the current verbosity.
*/
public void setVerbosity (int verbosity) {
this.verbosity = new Integer(verbosity);
debug.setDebug(verbosity);
}
/**
* What is the current verbosity?
*
* @deprecated No longer static; use get/set methods.
*/
public int verbosity () {
return getVerbosity();
}
/**
* Obtain the relativeCatalogs setting from the properties.
*
* @return The relativeCatalogs setting from the propertyFile or the
* defaultRelativeCatalogs.
*/
private boolean queryRelativeCatalogs () {
if (resources==null) readProperties();
if (resources==null) return defaultRelativeCatalogs;
try {
String allow = resources.getString("relative-catalogs");
return (allow.equalsIgnoreCase("true")
|| allow.equalsIgnoreCase("yes")
|| allow.equalsIgnoreCase("1"));
} catch (MissingResourceException e) {
return defaultRelativeCatalogs;
}
}
/**
* Get the relativeCatalogs setting.
*
* <p>This property is used when the catalogFiles property is
* interrogated. If true, then relative catalog entry file names
* are returned. If false, relative catalog entry file names are
* made absolute with respect to the properties file before returning
* them.</p>
*
* <p>This property <emph>only applies</emph> when the catalog files
* come from a properties file. If they come from a system property or
* the default list, they are never considered relative. (What would
* they be relative to?)</p>
*
* <p>In the properties, a value of 'yes', 'true', or '1' is considered
* true, anything else is false.</p>
*
* @return The relativeCatalogs setting from the propertyFile or the
* defaultRelativeCatalogs.
*/
public boolean getRelativeCatalogs () {
if (relativeCatalogs == null) {
relativeCatalogs = new Boolean(queryRelativeCatalogs());
}
return relativeCatalogs.booleanValue();
}
/**
* Set the relativeCatalogs setting.
*
* @see #getRelativeCatalogs()
*/
public void setRelativeCatalogs (boolean relative) {
relativeCatalogs = new Boolean(relative);
}
/**
* Get the relativeCatalogs setting.
*
* @deprecated No longer static; use get/set methods.
*/
public boolean relativeCatalogs () {
return getRelativeCatalogs();
}
/**
* Obtain the list of catalog files from the properties.
*
* @return A semicolon delimited list of catlog file URIs
*/
private String queryCatalogFiles () {
String catalogList = SecuritySupport.getSystemProperty(pFiles);
fromPropertiesFile = false;
if (catalogList == null) {
if (resources == null) readProperties();
if (resources != null) {
try {
catalogList = resources.getString("catalogs");
fromPropertiesFile = true;
} catch (MissingResourceException e) {
System.err.println(propertyFile + ": catalogs not found.");
catalogList = null;
}
}
}
if (catalogList == null) {
catalogList = defaultCatalogFiles;
}
return catalogList;
}
/**
* Return the current list of catalog files.
*
* @return A vector of the catalog file names or null if no catalogs
* are available in the properties.
*/
public Vector getCatalogFiles() {
if (catalogFiles == null) {
catalogFiles = queryCatalogFiles();
}
StringTokenizer files = new StringTokenizer(catalogFiles, ";");
Vector catalogs = new Vector();
while (files.hasMoreTokens()) {
String catalogFile = files.nextToken();
URL absURI = null;
if (fromPropertiesFile && !relativeCatalogs()) {
try {
absURI = new URL(propertyFileURI, catalogFile);
catalogFile = absURI.toString();
} catch (MalformedURLException mue) {
absURI = null;
}
}
catalogs.add(catalogFile);
}
return catalogs;
}
/**
* Set the list of catalog files.
*/
public void setCatalogFiles(String fileList) {
catalogFiles = fileList;
fromPropertiesFile = false;
}
/**
* Return the current list of catalog files.
*
* @return A vector of the catalog file names or null if no catalogs
* are available in the properties.
*
* @deprecated No longer static; use get/set methods.
*/
public Vector catalogFiles() {
return getCatalogFiles();
}
/**
* Obtain the preferPublic setting from the properties.
*
* <p>In the properties, a value of 'public' is true,
* anything else is false.</p>
*
* @return True if prefer is public or the
* defaultPreferSetting.
*/
private boolean queryPreferPublic () {
String prefer = SecuritySupport.getSystemProperty(pPrefer);
if (prefer == null) {
if (resources==null) readProperties();
if (resources==null) return defaultPreferPublic;
try {
prefer = resources.getString("prefer");
} catch (MissingResourceException e) {
return defaultPreferPublic;
}
}
if (prefer == null) {
return defaultPreferPublic;
}
return (prefer.equalsIgnoreCase("public"));
}
/**
* Return the current prefer public setting.
*
* @return True if public identifiers are preferred.
*/
public boolean getPreferPublic () {
if (preferPublic == null) {
preferPublic = new Boolean(queryPreferPublic());
}
return preferPublic.booleanValue();
}
/**
* Set the prefer public setting.
*/
public void setPreferPublic (boolean preferPublic) {
this.preferPublic = new Boolean(preferPublic);
}
/**
* Return the current prefer public setting.
*
* @return True if public identifiers are preferred.
*
* @deprecated No longer static; use get/set methods.
*/
public boolean preferPublic () {
return getPreferPublic();
}
/**
* Obtain the static-catalog setting from the properties.
*
* <p>In the properties, a value of 'yes', 'true', or '1' is considered
* true, anything else is false.</p>
*
* @return The static-catalog setting from the propertyFile or the
* defaultUseStaticCatalog.
*/
private boolean queryUseStaticCatalog () {
String staticCatalog = SecuritySupport.getSystemProperty(pStatic);
if (staticCatalog == null) {
if (resources==null) readProperties();
if (resources==null) return defaultUseStaticCatalog;
try {
staticCatalog = resources.getString("static-catalog");
} catch (MissingResourceException e) {
return defaultUseStaticCatalog;
}
}
if (staticCatalog == null) {
return defaultUseStaticCatalog;
}
return (staticCatalog.equalsIgnoreCase("true")
|| staticCatalog.equalsIgnoreCase("yes")
|| staticCatalog.equalsIgnoreCase("1"));
}
/**
* Get the current use static catalog setting.
*/
public boolean getUseStaticCatalog() {
if (useStaticCatalog == null) {
useStaticCatalog = new Boolean(queryUseStaticCatalog());
}
return useStaticCatalog.booleanValue();
}
/**
* Set the use static catalog setting.
*/
public void setUseStaticCatalog(boolean useStatic) {
useStaticCatalog = new Boolean(useStatic);
}
/**
* Get the current use static catalog setting.
*
* @deprecated No longer static; use get/set methods.
*/
public boolean staticCatalog() {
return getUseStaticCatalog();
}
/**
* Get a new catalog instance.
*
* This method always returns a new instance of the underlying catalog class.
*/
public Catalog getPrivateCatalog() {
Catalog catalog = staticCatalog;
if (useStaticCatalog == null) {
useStaticCatalog = new Boolean(getUseStaticCatalog());
}
if (catalog == null || !useStaticCatalog.booleanValue()) {
try {
String catalogClassName = getCatalogClassName();
if (catalogClassName == null) {
catalog = new Catalog();
} else {
try {
catalog = (Catalog) ReflectUtil.forName(catalogClassName).newInstance();
} catch (ClassNotFoundException cnfe) {
debug.message(1,"Catalog class named '"
+ catalogClassName
+ "' could not be found. Using default.");
catalog = new Catalog();
} catch (ClassCastException cnfe) {
debug.message(1,"Class named '"
+ catalogClassName
+ "' is not a Catalog. Using default.");
catalog = new Catalog();
}
}
catalog.setCatalogManager(this);
catalog.setupReaders();
catalog.loadSystemCatalogs();
} catch (Exception ex) {
ex.printStackTrace();
}
if (useStaticCatalog.booleanValue()) {
staticCatalog = catalog;
}
}
return catalog;
}
/**
* Get a catalog instance.
*
* If this manager uses static catalogs, the same static catalog will
* always be returned. Otherwise a new catalog will be returned.
*/
public Catalog getCatalog() {
Catalog catalog = staticCatalog;
if (useStaticCatalog == null) {
useStaticCatalog = new Boolean(getUseStaticCatalog());
}
if (catalog == null || !useStaticCatalog.booleanValue()) {
catalog = getPrivateCatalog();
if (useStaticCatalog.booleanValue()) {
staticCatalog = catalog;
}
}
return catalog;
}
/**
* <p>Obtain the oasisXMLCatalogPI setting from the properties.</p>
*
* <p>In the properties, a value of 'yes', 'true', or '1' is considered
* true, anything else is false.</p>
*
* @return The oasisXMLCatalogPI setting from the propertyFile or the
* defaultOasisXMLCatalogPI.
*/
public boolean queryAllowOasisXMLCatalogPI () {
String allow = SecuritySupport.getSystemProperty(pAllowPI);
if (allow == null) {
if (resources==null) readProperties();
if (resources==null) return defaultOasisXMLCatalogPI;
try {
allow = resources.getString("allow-oasis-xml-catalog-pi");
} catch (MissingResourceException e) {
return defaultOasisXMLCatalogPI;
}
}
if (allow == null) {
return defaultOasisXMLCatalogPI;
}
return (allow.equalsIgnoreCase("true")
|| allow.equalsIgnoreCase("yes")
|| allow.equalsIgnoreCase("1"));
}
/**
* Get the current XML Catalog PI setting.
*/
public boolean getAllowOasisXMLCatalogPI () {
if (oasisXMLCatalogPI == null) {
oasisXMLCatalogPI = new Boolean(queryAllowOasisXMLCatalogPI());
}
return oasisXMLCatalogPI.booleanValue();
}
public boolean overrideDefaultParser() {
return overrideDefaultParser;
}
/**
* Set the XML Catalog PI setting
*/
public void setAllowOasisXMLCatalogPI(boolean allowPI) {
oasisXMLCatalogPI = new Boolean(allowPI);
}
/**
* Get the current XML Catalog PI setting.
*
* @deprecated No longer static; use get/set methods.
*/
public boolean allowOasisXMLCatalogPI() {
return getAllowOasisXMLCatalogPI();
}
/**
* Obtain the Catalog class name setting from the properties.
*
*/
public String queryCatalogClassName () {
String className = SecuritySupport.getSystemProperty(pClassname);
if (className == null) {
if (resources==null) readProperties();
if (resources==null) return null;
try {
return resources.getString("catalog-class-name");
} catch (MissingResourceException e) {
return null;
}
}
return className;
}
/**
* Get the current Catalog class name.
*/
public String getCatalogClassName() {
if (catalogClassName == null) {
catalogClassName = queryCatalogClassName();
}
return catalogClassName;
}
/**
* Set the Catalog class name.
*/
public void setCatalogClassName(String className) {
catalogClassName = className;
}
/**
* Get the current Catalog class name.
*
* @deprecated No longer static; use get/set methods.
*/
public String catalogClassName() {
return getCatalogClassName();
}
}

View File

@@ -0,0 +1,695 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// Resolver.java - Represents an extension of OASIS Open Catalog files.
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileNotFoundException;
import java.util.Enumeration;
import java.util.Vector;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import javax.xml.parsers.SAXParserFactory;
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
import com.sun.org.apache.xml.internal.resolver.readers.SAXCatalogReader;
import com.sun.org.apache.xml.internal.resolver.readers.OASISXMLCatalogReader;
import com.sun.org.apache.xml.internal.resolver.readers.TR9401CatalogReader;
import jdk.xml.internal.JdkXmlUtils;
/**
* An extension to OASIS Open Catalog files, this class supports
* suffix-based matching and an external RFC2483 resolver.
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public class Resolver extends Catalog {
/**
* The URISUFFIX Catalog Entry type.
*
* <p>URI suffix entries match URIs that end in a specified suffix.</p>
*/
public static final int URISUFFIX = CatalogEntry.addEntryType("URISUFFIX", 2);
/**
* The SYSTEMSUFFIX Catalog Entry type.
*
* <p>System suffix entries match system identifiers that end in a
* specified suffix.</p>
*/
public static final int SYSTEMSUFFIX = CatalogEntry.addEntryType("SYSTEMSUFFIX", 2);
/**
* The RESOLVER Catalog Entry type.
*
* <p>A hook for providing support for web-based backup resolvers.</p>
*/
public static final int RESOLVER = CatalogEntry.addEntryType("RESOLVER", 1);
/**
* The SYSTEMREVERSE Catalog Entry type.
*
* <p>This is a bit of a hack. There's no actual SYSTEMREVERSE entry,
* but this entry type is used to indicate that a reverse lookup is
* being performed. (This allows the Resolver to implement
* RFC2483 I2N and I2NS.)
*/
public static final int SYSTEMREVERSE
= CatalogEntry.addEntryType("SYSTEMREVERSE", 1);
/**
* Setup readers.
*/
public void setupReaders() {
SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser());
spf.setValidating(false);
SAXCatalogReader saxReader = new SAXCatalogReader(spf);
saxReader.setCatalogParser(null, "XMLCatalog",
"com.sun.org.apache.xml.internal.resolver.readers.XCatalogReader");
saxReader.setCatalogParser(OASISXMLCatalogReader.namespaceName,
"catalog",
"com.sun.org.apache.xml.internal.resolver.readers.ExtendedXMLCatalogReader");
addReader("application/xml", saxReader);
TR9401CatalogReader textReader = new TR9401CatalogReader();
addReader("text/plain", textReader);
}
/**
* Cleanup and process a Catalog entry.
*
* <p>This method processes each Catalog entry, changing mapped
* relative system identifiers into absolute ones (based on the current
* base URI), and maintaining other information about the current
* catalog.</p>
*
* @param entry The CatalogEntry to process.
*/
public void addEntry(CatalogEntry entry) {
int type = entry.getEntryType();
if (type == URISUFFIX) {
String suffix = normalizeURI(entry.getEntryArg(0));
String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
entry.setEntryArg(1, fsi);
catalogManager.debug.message(4, "URISUFFIX", suffix, fsi);
} else if (type == SYSTEMSUFFIX) {
String suffix = normalizeURI(entry.getEntryArg(0));
String fsi = makeAbsolute(normalizeURI(entry.getEntryArg(1)));
entry.setEntryArg(1, fsi);
catalogManager.debug.message(4, "SYSTEMSUFFIX", suffix, fsi);
}
super.addEntry(entry);
}
/**
* Return the applicable URI.
*
* <p>If a URI entry exists in the Catalog
* for the URI specified, return the mapped value.</p>
*
* <p>In the Resolver (as opposed to the Catalog) class, if the
* URI isn't found by the usual algorithm, URISUFFIX entries are
* considered.</p>
*
* <p>URI comparison is case sensitive.</p>
*
* @param uri The URI to locate in the catalog.
*
* @return The resolved URI.
*
* @throws MalformedURLException The system identifier of a
* subordinate catalog cannot be turned into a valid URL.
* @throws IOException Error reading subordinate catalog file.
*/
public String resolveURI(String uri)
throws MalformedURLException, IOException {
String resolved = super.resolveURI(uri);
if (resolved != null) {
return resolved;
}
Enumeration en = catalogEntries.elements();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == RESOLVER) {
resolved = resolveExternalSystem(uri, e.getEntryArg(0));
if (resolved != null) {
return resolved;
}
} else if (e.getEntryType() == URISUFFIX) {
String suffix = e.getEntryArg(0);
String result = e.getEntryArg(1);
if (suffix.length() <= uri.length()
&& uri.substring(uri.length()-suffix.length()).equals(suffix)) {
return result;
}
}
}
// Otherwise, look in the subordinate catalogs
return resolveSubordinateCatalogs(Catalog.URI,
null,
null,
uri);
}
/**
* Return the applicable SYSTEM system identifier, resorting
* to external RESOLVERs if necessary.
*
* <p>If a SYSTEM entry exists in the Catalog
* for the system ID specified, return the mapped value.</p>
*
* <p>In the Resolver (as opposed to the Catalog) class, if the
* URI isn't found by the usual algorithm, SYSTEMSUFFIX entries are
* considered.</p>
*
* <p>On Windows-based operating systems, the comparison between
* the system identifier provided and the SYSTEM entries in the
* Catalog is case-insensitive.</p>
*
* @param systemId The system ID to locate in the catalog.
*
* @return The system identifier to use for systemId.
*
* @throws MalformedURLException The formal system identifier of a
* subordinate catalog cannot be turned into a valid URL.
* @throws IOException Error reading subordinate catalog file.
*/
public String resolveSystem(String systemId)
throws MalformedURLException, IOException {
String resolved = super.resolveSystem(systemId);
if (resolved != null) {
return resolved;
}
Enumeration en = catalogEntries.elements();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == RESOLVER) {
resolved = resolveExternalSystem(systemId, e.getEntryArg(0));
if (resolved != null) {
return resolved;
}
} else if (e.getEntryType() == SYSTEMSUFFIX) {
String suffix = e.getEntryArg(0);
String result = e.getEntryArg(1);
if (suffix.length() <= systemId.length()
&& systemId.substring(systemId.length()-suffix.length()).equals(suffix)) {
return result;
}
}
}
return resolveSubordinateCatalogs(Catalog.SYSTEM,
null,
null,
systemId);
}
/**
* Return the applicable PUBLIC or SYSTEM identifier, resorting
* to external resolvers if necessary.
*
* <p>This method searches the Catalog and returns the system
* identifier specified for the given system or
* public identifiers. If
* no appropriate PUBLIC or SYSTEM entry is found in the Catalog,
* null is returned.</p>
*
* <p>Note that a system or public identifier in the current catalog
* (or subordinate catalogs) will be used in preference to an
* external resolver. Further, if a systemId is present, the external
* resolver(s) will be queried for that before the publicId.</p>
*
* @param publicId The public identifier to locate in the catalog.
* Public identifiers are normalized before comparison.
* @param systemId The nominal system identifier for the entity
* in question (as provided in the source document).
*
* @throws MalformedURLException The formal system identifier of a
* subordinate catalog cannot be turned into a valid URL.
* @throws IOException Error reading subordinate catalog file.
*
* @return The system identifier to use.
* Note that the nominal system identifier is not returned if a
* match is not found in the catalog, instead null is returned
* to indicate that no match was found.
*/
public String resolvePublic(String publicId, String systemId)
throws MalformedURLException, IOException {
String resolved = super.resolvePublic(publicId, systemId);
if (resolved != null) {
return resolved;
}
Enumeration en = catalogEntries.elements();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == RESOLVER) {
if (systemId != null) {
resolved = resolveExternalSystem(systemId,
e.getEntryArg(0));
if (resolved != null) {
return resolved;
}
}
resolved = resolveExternalPublic(publicId, e.getEntryArg(0));
if (resolved != null) {
return resolved;
}
}
}
return resolveSubordinateCatalogs(Catalog.PUBLIC,
null,
publicId,
systemId);
}
/**
* Query an external RFC2483 resolver for a system identifier.
*
* @param systemId The system ID to locate.
* @param resolver The name of the resolver to use.
*
* @return The system identifier to use for the systemId.
*/
protected String resolveExternalSystem(String systemId, String resolver)
throws MalformedURLException, IOException {
Resolver r = queryResolver(resolver, "i2l", systemId, null);
if (r != null) {
return r.resolveSystem(systemId);
} else {
return null;
}
}
/**
* Query an external RFC2483 resolver for a public identifier.
*
* @param publicId The system ID to locate.
* @param resolver The name of the resolver to use.
*
* @return The system identifier to use for the systemId.
*/
protected String resolveExternalPublic(String publicId, String resolver)
throws MalformedURLException, IOException {
Resolver r = queryResolver(resolver, "fpi2l", publicId, null);
if (r != null) {
return r.resolvePublic(publicId, null);
} else {
return null;
}
}
/**
* Query an external RFC2483 resolver.
*
* @param resolver The URL of the RFC2483 resolver.
* @param command The command to send the resolver.
* @param arg1 The first argument to the resolver.
* @param arg2 The second argument to the resolver, usually null.
*
* @return The Resolver constructed.
*/
protected Resolver queryResolver(String resolver,
String command,
String arg1,
String arg2) {
InputStream iStream = null;
String RFC2483 = resolver + "?command=" + command
+ "&format=tr9401&uri=" + arg1
+ "&uri2=" + arg2;
String line = null;
try {
URL url = new URL(RFC2483);
URLConnection urlCon = url.openConnection();
urlCon.setUseCaches(false);
Resolver r = (Resolver) newCatalog();
String cType = urlCon.getContentType();
// I don't care about the character set or subtype
if (cType.indexOf(";") > 0) {
cType = cType.substring(0, cType.indexOf(";"));
}
r.parseCatalog(cType, urlCon.getInputStream());
return r;
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.UNPARSEABLE) {
catalogManager.debug.message(1, "Unparseable catalog: " + RFC2483);
} else if (cex.getExceptionType()
== CatalogException.UNKNOWN_FORMAT) {
catalogManager.debug.message(1, "Unknown catalog format: " + RFC2483);
}
return null;
} catch (MalformedURLException mue) {
catalogManager.debug.message(1, "Malformed resolver URL: " + RFC2483);
return null;
} catch (IOException ie) {
catalogManager.debug.message(1, "I/O Exception opening resolver: " + RFC2483);
return null;
}
}
/**
* Append two vectors, returning the result.
*
* @param vec The first vector
* @param appvec The vector to be appended
* @return The vector vec, with appvec's elements appended to it
*/
private Vector appendVector(Vector vec, Vector appvec) {
if (appvec != null) {
for (int count = 0; count < appvec.size(); count++) {
vec.addElement(appvec.elementAt(count));
}
}
return vec;
}
/**
* Find the URNs for a given system identifier in all catalogs.
*
* @param systemId The system ID to locate.
*
* @return A vector of URNs that map to the systemId.
*/
public Vector resolveAllSystemReverse(String systemId)
throws MalformedURLException, IOException {
Vector resolved = new Vector();
// If there's a SYSTEM entry in this catalog, use it
if (systemId != null) {
Vector localResolved = resolveLocalSystemReverse(systemId);
resolved = appendVector(resolved, localResolved);
}
// Otherwise, look in the subordinate catalogs
Vector subResolved = resolveAllSubordinateCatalogs(SYSTEMREVERSE,
null,
null,
systemId);
return appendVector(resolved, subResolved);
}
/**
* Find the URN for a given system identifier.
*
* @param systemId The system ID to locate.
*
* @return A (single) URN that maps to the systemId.
*/
public String resolveSystemReverse(String systemId)
throws MalformedURLException, IOException {
Vector resolved = resolveAllSystemReverse(systemId);
if (resolved != null && resolved.size() > 0) {
return (String) resolved.elementAt(0);
} else {
return null;
}
}
/**
* Return the applicable SYSTEM system identifiers.
*
* <p>If one or more SYSTEM entries exists in the Catalog
* for the system ID specified, return the mapped values.</p>
*
* <p>The caller is responsible for doing any necessary
* normalization of the system identifier before calling
* this method. For example, a relative system identifier in
* a document might be converted to an absolute system identifier
* before attempting to resolve it.</p>
*
* <p>Note that this function will force all subordinate catalogs
* to be loaded.</p>
*
* <p>On Windows-based operating systems, the comparison between
* the system identifier provided and the SYSTEM entries in the
* Catalog is case-insensitive.</p>
*
* @param systemId The system ID to locate in the catalog.
*
* @return The system identifier to use for the notation.
*
* @throws MalformedURLException The formal system identifier of a
* subordinate catalog cannot be turned into a valid URL.
* @throws IOException Error reading subordinate catalog file.
*/
public Vector resolveAllSystem(String systemId)
throws MalformedURLException, IOException {
Vector resolutions = new Vector();
// If there are SYSTEM entries in this catalog, start with them
if (systemId != null) {
Vector localResolutions = resolveAllLocalSystem(systemId);
resolutions = appendVector(resolutions, localResolutions);
}
// Then look in the subordinate catalogs
Vector subResolutions = resolveAllSubordinateCatalogs(SYSTEM,
null,
null,
systemId);
resolutions = appendVector(resolutions, subResolutions);
if (resolutions.size() > 0) {
return resolutions;
} else {
return null;
}
}
/**
* Return all applicable SYSTEM system identifiers in this
* catalog.
*
* <p>If one or more SYSTEM entries exists in the catalog file
* for the system ID specified, return the mapped values.</p>
*
* @param systemId The system ID to locate in the catalog
*
* @return A vector of the mapped system identifiers or null
*/
private Vector resolveAllLocalSystem(String systemId) {
Vector map = new Vector();
String osname = SecuritySupport.getSystemProperty("os.name");
boolean windows = (osname.indexOf("Windows") >= 0);
Enumeration en = catalogEntries.elements();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == SYSTEM
&& (e.getEntryArg(0).equals(systemId)
|| (windows
&& e.getEntryArg(0).equalsIgnoreCase(systemId)))) {
map.addElement(e.getEntryArg(1));
}
}
if (map.size() == 0) {
return null;
} else {
return map;
}
}
/**
* Find the URNs for a given system identifier in the current catalog.
*
* @param systemId The system ID to locate.
*
* @return A vector of URNs that map to the systemId.
*/
private Vector resolveLocalSystemReverse(String systemId) {
Vector map = new Vector();
String osname = SecuritySupport.getSystemProperty("os.name");
boolean windows = (osname.indexOf("Windows") >= 0);
Enumeration en = catalogEntries.elements();
while (en.hasMoreElements()) {
CatalogEntry e = (CatalogEntry) en.nextElement();
if (e.getEntryType() == SYSTEM
&& (e.getEntryArg(1).equals(systemId)
|| (windows
&& e.getEntryArg(1).equalsIgnoreCase(systemId)))) {
map.addElement(e.getEntryArg(0));
}
}
if (map.size() == 0) {
return null;
} else {
return map;
}
}
/**
* Search the subordinate catalogs, in order, looking for all
* match.
*
* <p>This method searches the Catalog and returns all of the system
* identifiers specified for the given entity type with the given
* name, public, and system identifiers. In some contexts, these
* may be null.</p>
*
* @param entityType The CatalogEntry type for which this query is
* being conducted. This is necessary in order to do the approprate
* query on a subordinate catalog.
* @param entityName The name of the entity being searched for, if
* appropriate.
* @param publicId The public identifier of the entity in question
* (as provided in the source document).
* @param systemId The nominal system identifier for the entity
* in question (as provided in the source document).
*
* @throws MalformedURLException The formal system identifier of a
* delegated catalog cannot be turned into a valid URL.
* @throws IOException Error reading delegated catalog file.
*
* @return The system identifier to use.
* Note that the nominal system identifier is not returned if a
* match is not found in the catalog, instead null is returned
* to indicate that no match was found.
*/
private synchronized Vector resolveAllSubordinateCatalogs(int entityType,
String entityName,
String publicId,
String systemId)
throws MalformedURLException, IOException {
Vector resolutions = new Vector();
for (int catPos = 0; catPos < catalogs.size(); catPos++) {
Resolver c = null;
try {
c = (Resolver) catalogs.elementAt(catPos);
} catch (ClassCastException e) {
String catfile = (String) catalogs.elementAt(catPos);
c = (Resolver) newCatalog();
try {
c.parseCatalog(catfile);
} catch (MalformedURLException mue) {
catalogManager.debug.message(1, "Malformed Catalog URL", catfile);
} catch (FileNotFoundException fnfe) {
catalogManager.debug.message(1, "Failed to load catalog, file not found",
catfile);
} catch (IOException ioe) {
catalogManager.debug.message(1, "Failed to load catalog, I/O error", catfile);
}
catalogs.setElementAt(c, catPos);
}
String resolved = null;
// Ok, now what are we supposed to call here?
if (entityType == DOCTYPE) {
resolved = c.resolveDoctype(entityName,
publicId,
systemId);
if (resolved != null) {
// Only find one DOCTYPE resolution
resolutions.addElement(resolved);
return resolutions;
}
} else if (entityType == DOCUMENT) {
resolved = c.resolveDocument();
if (resolved != null) {
// Only find one DOCUMENT resolution
resolutions.addElement(resolved);
return resolutions;
}
} else if (entityType == ENTITY) {
resolved = c.resolveEntity(entityName,
publicId,
systemId);
if (resolved != null) {
// Only find one ENTITY resolution
resolutions.addElement(resolved);
return resolutions;
}
} else if (entityType == NOTATION) {
resolved = c.resolveNotation(entityName,
publicId,
systemId);
if (resolved != null) {
// Only find one NOTATION resolution
resolutions.addElement(resolved);
return resolutions;
}
} else if (entityType == PUBLIC) {
resolved = c.resolvePublic(publicId, systemId);
if (resolved != null) {
// Only find one PUBLIC resolution
resolutions.addElement(resolved);
return resolutions;
}
} else if (entityType == SYSTEM) {
Vector localResolutions = c.resolveAllSystem(systemId);
resolutions = appendVector(resolutions, localResolutions);
break;
} else if (entityType == SYSTEMREVERSE) {
Vector localResolutions = c.resolveAllSystemReverse(systemId);
resolutions = appendVector(resolutions, localResolutions);
}
}
if (resolutions != null) {
return resolutions;
} else {
return null;
}
}
}

View File

@@ -0,0 +1,200 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// BootstrapResolver.java - Resolve entities and URIs internally
package com.sun.org.apache.xml.internal.resolver.helpers;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import javax.xml.transform.sax.SAXSource;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
/**
* A simple bootstrapping resolver.
*
* <p>This class is used as the entity resolver when reading XML Catalogs.
* It searches for the OASIS XML Catalog DTD, Relax NG Grammar and W3C XML Schema
* as resources (e.g., in the resolver jar file).</p>
*
* <p>If you have your own DTDs or schemas, you can extend this class and
* set the BootstrapResolver in your CatalogManager.</p>
*
* @see com.sun.org.apache.xml.internal.resolver.CatalogManager
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class BootstrapResolver implements EntityResolver, URIResolver {
/** URI of the W3C XML Schema for OASIS XML Catalog files. */
public static final String xmlCatalogXSD = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.xsd";
/** URI of the RELAX NG Grammar for OASIS XML Catalog files. */
public static final String xmlCatalogRNG = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.rng";
/** Public identifier for OASIS XML Catalog files. */
public static final String xmlCatalogPubId = "-//OASIS//DTD XML Catalogs V1.0//EN";
/** System identifier for OASIS XML Catalog files. */
public static final String xmlCatalogSysId = "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd";
/** Private hash used for public identifiers. */
private final Map<String, String> publicMap = new HashMap<>();
/** Private hash used for system identifiers. */
private final Map<String, String> systemMap = new HashMap<>();
/** Private hash used for URIs. */
private final Map<String, String> uriMap = new HashMap<>();
/** Constructor. */
public BootstrapResolver() {
URL url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/catalog.dtd");
if (url != null) {
publicMap.put(xmlCatalogPubId, url.toString());
systemMap.put(xmlCatalogSysId, url.toString());
}
url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/catalog.rng");
if (url != null) {
uriMap.put(xmlCatalogRNG, url.toString());
}
url = this.getClass().getResource("/com/sun/org/apache/xml/internal/resolver/etc/catalog.xsd");
if (url != null) {
uriMap.put(xmlCatalogXSD, url.toString());
}
}
/** SAX resolveEntity API. */
public InputSource resolveEntity (String publicId, String systemId) {
String resolved = null;
if (systemId != null && systemMap.containsKey(systemId)) {
resolved = systemMap.get(systemId);
} else if (publicId != null && publicMap.containsKey(publicId)) {
resolved = publicMap.get(publicId);
}
if (resolved != null) {
try {
InputSource iSource = new InputSource(resolved);
iSource.setPublicId(publicId);
// Ideally this method would not attempt to open the
// InputStream, but there is a bug (in Xerces, at least)
// that causes the parser to mistakenly open the wrong
// system identifier if the returned InputSource does
// not have a byteStream.
//
// It could be argued that we still shouldn't do this here,
// but since the purpose of calling the entityResolver is
// almost certainly to open the input stream, it seems to
// do little harm.
//
URL url = new URL(resolved);
InputStream iStream = url.openStream();
iSource.setByteStream(iStream);
return iSource;
} catch (Exception e) {
// FIXME: silently fail?
return null;
}
}
return null;
}
/** Transformer resolve API. */
public Source resolve(String href, String base)
throws TransformerException {
String uri = href;
String fragment = null;
int hashPos = href.indexOf("#");
if (hashPos >= 0) {
uri = href.substring(0, hashPos);
fragment = href.substring(hashPos+1);
}
String result = null;
if (href != null && uriMap.containsKey(href)) {
result = uriMap.get(href);
}
if (result == null) {
try {
URL url = null;
if (base==null) {
url = new URL(uri);
result = url.toString();
} else {
URL baseURL = new URL(base);
url = (href.length()==0 ? baseURL : new URL(baseURL, uri));
result = url.toString();
}
} catch (java.net.MalformedURLException mue) {
// try to make an absolute URI from the current base
String absBase = makeAbsolute(base);
if (!absBase.equals(base)) {
// don't bother if the absBase isn't different!
return resolve(href, absBase);
} else {
throw new TransformerException("Malformed URL "
+ href + "(base " + base + ")",
mue);
}
}
}
SAXSource source = new SAXSource();
source.setInputSource(new InputSource(result));
return source;
}
/** Attempt to construct an absolute URI */
private String makeAbsolute(String uri) {
if (uri == null) {
uri = "";
}
try {
URL url = new URL(uri);
return url.toString();
} catch (MalformedURLException mue) {
try {
URL fileURL = FileURL.makeURL(uri);
return fileURL.toString();
} catch (MalformedURLException mue2) {
// bail
return uri;
}
}
}
}

View File

@@ -0,0 +1,111 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// Debug.java - Print debug messages
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.helpers;
/**
* Static debugging/messaging class for Catalogs.
*
* <p>This class defines a set of static methods that can be called
* to produce debugging messages. Messages have an associated "debug
* level" and messages below the current setting are not displayed.</p>
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class Debug {
/** The internal debug level. */
protected int debug = 0;
/** Constructor */
public Debug() {
// nop
}
/** Set the debug level for future messages. */
public void setDebug(int newDebug) {
debug = newDebug;
}
/** Get the current debug level. */
public int getDebug() {
return debug;
}
/**
* Print debug message (if the debug level is high enough).
*
* <p>Prints "the message"</p>
*
* @param level The debug level of this message. This message
* will only be
* displayed if the current debug level is at least equal to this
* value.
* @param message The text of the message.
*/
public void message(int level, String message) {
if (debug >= level) {
System.out.println(message);
}
}
/**
* Print debug message (if the debug level is high enough).
*
* <p>Prints "the message: spec"</p>
*
* @param level The debug level of this message. This message
* will only be
* displayed if the current debug level is at least equal to this
* value.
* @param message The text of the message.
* @param spec An argument to the message.
*/
public void message(int level, String message, String spec) {
if (debug >= level) {
System.out.println(message + ": " + spec);
}
}
/**
* Print debug message (if the debug level is high enough).
*
* <p>Prints "the message: spec1" and "spec2" indented on the next line.</p>
*
* @param level The debug level of this message. This message
* will only be
* displayed if the current debug level is at least equal to this
* value.
* @param message The text of the message.
* @param spec1 An argument to the message.
* @param spec2 Another argument to the message.
*/
public void message(int level, String message,
String spec1, String spec2) {
if (debug >= level) {
System.out.println(message + ": " + spec1);
System.out.println("\t" + spec2);
}
}
}

View File

@@ -0,0 +1,93 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// FileURL.java - Construct a file: scheme URL
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.helpers;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.File;
/**
* Static method for dealing with file: URLs.
*
* <p>This class defines a static method that can be used to construct
* an appropriate file: URL from parts. It's defined here so that it
* can be reused throught the resolver.</p>
*
* <p>(Yes, I'd rather have called this class FileUR<b>I</b>, but
* given that a jave.net.URL is returned, it seemed...even more
* confusing.)</p>
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public abstract class FileURL {
protected FileURL() { }
/**
* Construct a file: URL for a path name.
*
* <p>URLs in the file: scheme can be constructed for paths on
* the local file system. Several possibilities need to be considered:
* </p>
*
* <ul>
* <li>If the path does not begin with a slash, then it is assumed
* to reside in the users current working directory
* (System.getProperty("user.dir")).</li>
* <li>On Windows machines, the current working directory uses
* backslashes (\\, instead of /).</li>
* <li>If the current working directory is "/", don't add an extra
* slash before the base name.</li>
* </ul>
*
* <p>This method is declared static so that other classes
* can use it directly.</p>
*
* @param pathname The path name component for which to construct a URL.
*
* @return The appropriate file: URL.
*
* @throws MalformedURLException if the pathname can't be turned into
* a proper URL.
*/
public static URL makeURL(String pathname) throws MalformedURLException {
/*if (pathname.startsWith("/")) {
return new URL("file://" + pathname);
}
String userdir = System.getProperty("user.dir");
userdir.replace('\\', '/');
if (userdir.endsWith("/")) {
return new URL("file:///" + userdir + pathname);
} else {
return new URL("file:///" + userdir + "/" + pathname);
}
*/
File file = new File(pathname);
return file.toURI().toURL();
}
}

View File

@@ -0,0 +1,114 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// Namespaces.java - Analyze namespace nodes in a DOM tree
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.helpers;
import org.w3c.dom.*;
/**
* Static Namespace query methods.
*
* <p>This class defines a set of static methods that can be called
* to analyze the namespace properties of DOM nodes.</p>
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class Namespaces {
/**
* Returns the "prefix" part of a QName or the empty string (not
* null) if the name has no prefix.
*
* @param element The QName of an element.
* @return The prefix part of the element name.
*/
public static String getPrefix(Element element) {
String name = element.getTagName();
String prefix = "";
if (name.indexOf(':') > 0) {
prefix = name.substring(0, name.indexOf(':'));
}
return prefix;
}
/**
* Returns the "localname" part of a QName, which is the whole
* name if it has no prefix.
*
* @param element The QName of an element.
* @return The local part of a QName.
*/
public static String getLocalName(Element element) {
String name = element.getTagName();
if (name.indexOf(':') > 0) {
name = name.substring(name.indexOf(':')+1);
}
return name;
}
/**
* Returns the namespace URI for the specified prefix at the
* specified context node.
*
* @param node The context node.
* @param prefix The prefix.
* @return The namespace URI associated with the prefix, or
* null if no namespace declaration exists for the prefix.
*/
public static String getNamespaceURI(Node node, String prefix) {
if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
return null;
}
if (prefix.equals("")) {
if (((Element) node).hasAttribute("xmlns")) {
return ((Element) node).getAttribute("xmlns");
}
} else {
String nsattr = "xmlns:" + prefix;
if (((Element) node).hasAttribute(nsattr)) {
return ((Element) node).getAttribute(nsattr);
}
}
return getNamespaceURI(node.getParentNode(), prefix);
}
/**
* Returns the namespace URI for the namespace to which the
* element belongs.
*
* @param element The element.
* @return The namespace URI associated with the namespace of the
* element, or null if no namespace declaration exists for it.
*/
public static String getNamespaceURI(Element element) {
String prefix = getPrefix(element);
return getNamespaceURI(element, prefix);
}
}

View File

@@ -0,0 +1,161 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// PublicId.java - Information about public identifiers
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.helpers;
/**
* Static methods for dealing with public identifiers.
*
* <p>This class defines a set of static methods that can be called
* to handle public identifiers.</p>
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public abstract class PublicId {
protected PublicId() { }
/**
* Normalize a public identifier.
*
* <p>Public identifiers must be normalized according to the following
* rules before comparisons between them can be made:</p>
*
* <ul>
* <li>Whitespace characters are normalized to spaces (e.g., line feeds,
* tabs, etc. become spaces).</li>
* <li>Leading and trailing whitespace is removed.</li>
* <li>Multiple internal whitespaces are normalized to a single
* space.</li>
* </ul>
*
* <p>This method is declared static so that other classes
* can use it directly.</p>
*
* @param publicId The unnormalized public identifier.
*
* @return The normalized identifier.
*/
public static String normalize(String publicId) {
String normal = publicId.replace('\t', ' ');
normal = normal.replace('\r', ' ');
normal = normal.replace('\n', ' ');
normal = normal.trim();
int pos;
while ((pos = normal.indexOf(" ")) >= 0) {
normal = normal.substring(0, pos) + normal.substring(pos+1);
}
return normal;
}
/**
* Encode a public identifier as a "publicid" URN.
*
* <p>This method is declared static so that other classes
* can use it directly.</p>
*
* @param publicId The unnormalized public identifier.
*
* @return The normalized identifier.
*/
public static String encodeURN(String publicId) {
String urn = PublicId.normalize(publicId);
urn = PublicId.stringReplace(urn, "%", "%25");
urn = PublicId.stringReplace(urn, ";", "%3B");
urn = PublicId.stringReplace(urn, "'", "%27");
urn = PublicId.stringReplace(urn, "?", "%3F");
urn = PublicId.stringReplace(urn, "#", "%23");
urn = PublicId.stringReplace(urn, "+", "%2B");
urn = PublicId.stringReplace(urn, " ", "+");
urn = PublicId.stringReplace(urn, "::", ";");
urn = PublicId.stringReplace(urn, ":", "%3A");
urn = PublicId.stringReplace(urn, "//", ":");
urn = PublicId.stringReplace(urn, "/", "%2F");
return "urn:publicid:" + urn;
}
/**
* Decode a "publicid" URN into a public identifier.
*
* <p>This method is declared static so that other classes
* can use it directly.</p>
*
* @param urn The urn:publicid: URN
*
* @return The normalized identifier.
*/
public static String decodeURN(String urn) {
String publicId = "";
if (urn.startsWith("urn:publicid:")) {
publicId = urn.substring(13);
} else {
return urn;
}
publicId = PublicId.stringReplace(publicId, "%2F", "/");
publicId = PublicId.stringReplace(publicId, ":", "//");
publicId = PublicId.stringReplace(publicId, "%3A", ":");
publicId = PublicId.stringReplace(publicId, ";", "::");
publicId = PublicId.stringReplace(publicId, "+", " ");
publicId = PublicId.stringReplace(publicId, "%2B", "+");
publicId = PublicId.stringReplace(publicId, "%23", "#");
publicId = PublicId.stringReplace(publicId, "%3F", "?");
publicId = PublicId.stringReplace(publicId, "%27", "'");
publicId = PublicId.stringReplace(publicId, "%3B", ";");
publicId = PublicId.stringReplace(publicId, "%25", "%");
return publicId;
}
/**
* Replace one string with another.
*
*/
private static String stringReplace(String str,
String oldStr,
String newStr) {
String result = "";
int pos = str.indexOf(oldStr);
// System.out.println(str + ": " + oldStr + " => " + newStr);
while (pos >= 0) {
// System.out.println(str + " (" + pos + ")");
result += str.substring(0, pos);
result += newStr;
str = str.substring(pos+1);
pos = str.indexOf(oldStr);
}
return result + str;
}
}

View File

@@ -0,0 +1,81 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// CatalogReader.java - An interface for reading catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.io.IOException;
import java.net.MalformedURLException;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import java.io.InputStream;
import com.sun.org.apache.xml.internal.resolver.Catalog;
/**
* The CatalogReader interface.
*
* <p>The Catalog class requires that classes implement this interface
* in order to be used to read catalogs. Examples of CatalogReaders
* include the TextCatalogReader, the SAXCatalogReader, and the
* DOMCatalogReader.</p>
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public interface CatalogReader {
/**
* Read a catalog from a file.
*
* <p>This class reads a catalog from a URL.</p>
*
* @param catalog The catalog for which this reader is called.
* @param fileUrl The URL of a document to be read.
* @throws MalformedURLException if the specified URL cannot be
* turned into a URL object.
* @throws IOException if the URL cannot be read.
* @throws UnknownCatalogFormatException if the catalog format is
* not recognized.
* @throws UnparseableCatalogException if the catalog cannot be parsed.
* (For example, if it is supposed to be XML and isn't well-formed.)
*/
public void readCatalog(Catalog catalog, String fileUrl)
throws MalformedURLException, IOException, CatalogException;
/**
* Read a catalog from an input stream.
*
* <p>This class reads a catalog from an input stream.</p>
*
* @param catalog The catalog for which this reader is called.
* @param is The input stream that is to be read.
* @throws IOException if the URL cannot be read.
* @throws UnknownCatalogFormatException if the catalog format is
* not recognized.
* @throws UnparseableCatalogException if the catalog cannot be parsed.
* (For example, if it is supposed to be XML and isn't well-formed.)
*/
public void readCatalog(Catalog catalog, InputStream is)
throws IOException, CatalogException;
}

View File

@@ -0,0 +1,53 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// DOMCatalogParser.java - An interface for reading catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import org.w3c.dom.Node;
/**
* The DOMCatalogParser interface.
*
* <p>This interface must be implemented in order for a class to
* participate as a parser for the DOMCatalogReader.
*
* @see Catalog
* @see DOMCatalogReader
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public interface DOMCatalogParser {
/**
* Parse a DOM node as a catalog entry.
*
* <p>This method is expected to analyze the specified node and
* construct appropriate catalog entry(ies) from it.</p>
*
* @param catalog The catalog for which this node is being considered.
* @param node The DOM Node from the catalog.
*/
public void parseCatalogEntry(Catalog catalog, Node node);
}

View File

@@ -0,0 +1,243 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// DOMCatalogReader.java - Read XML Catalog files
package com.sun.org.apache.xml.internal.resolver.readers;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import com.sun.org.apache.xml.internal.resolver.helpers.Namespaces;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import sun.reflect.misc.ReflectUtil;
/**
* A DOM-based CatalogReader.
*
* <p>This class is used to read XML Catalogs using the DOM. This reader
* has an advantage over the SAX-based reader that it can analyze the
* DOM tree rather than simply a series of SAX events. It has the disadvantage
* that it requires all of the code necessary to build and walk a DOM
* tree.</p>
*
* <p>Since the choice of CatalogReaders (in the InputStream case) can only
* be made on the basis of MIME type, the following problem occurs: only
* one CatalogReader can exist for all XML mime types. In order to get
* around this problem, the DOMCatalogReader relies on a set of external
* CatalogParsers to actually build the catalog.</p>
*
* <p>The selection of CatalogParsers is made on the basis of the QName
* of the root element of the document.</p>
*
*
* @see Catalog
* @see CatalogReader
* @see SAXCatalogReader
* @see TextCatalogReader
* @see DOMCatalogParser
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class DOMCatalogReader implements CatalogReader {
/**
* Mapping table from QNames to CatalogParser classes.
*
* <p>Each key in this hash table has the form "elementname"
* or "{namespaceuri}elementname". The former is used if the
* namespace URI is null.</p>
*/
protected Map<String, String> namespaceMap = new HashMap<>();
/**
* Add a new parser to the reader.
*
* <p>This method associates the specified parserClass with the
* namespaceURI/rootElement names specified.</p>
*
* @param namespaceURI The namespace URI. <em>Not</em> the prefix.
* @param rootElement The name of the root element.
* @param parserClass The name of the parserClass to instantiate
* for this kind of catalog.
*/
public void setCatalogParser(String namespaceURI,
String rootElement,
String parserClass) {
if (namespaceURI == null) {
namespaceMap.put(rootElement, parserClass);
} else {
namespaceMap.put("{"+namespaceURI+"}"+rootElement, parserClass);
}
}
/**
* Get the name of the parser class for a given catalog type.
*
* <p>This method returns the parserClass associated with the
* namespaceURI/rootElement names specified.</p>
*
* @param namespaceURI The namespace URI. <em>Not</em> the prefix.
* @param rootElement The name of the root element.
* @return The parser class.
*/
public String getCatalogParser(String namespaceURI,
String rootElement) {
if (namespaceURI == null) {
return namespaceMap.get(rootElement);
} else {
return namespaceMap.get("{"+namespaceURI+"}"+rootElement);
}
}
/**
* Null constructor; something for subclasses to call.
*/
public DOMCatalogReader() { }
/**
* Read a catalog from an input stream.
*
* <p>This class reads a catalog from an input stream:</p>
*
* <ul>
* <li>Based on the QName of the root element, it determines which
* parser to instantiate for this catalog.</li>
* <li>It constructs a DOM Document from the catalog and</li>
* <li>For each child of the root node, it calls the parser's
* parseCatalogEntry method. This method is expected to make
* appropriate calls back into the catalog to add entries for the
* entries in the catalog. It is free to do this in whatever manner
* is appropriate (perhaps using just the node passed in, perhaps
* wandering arbitrarily throughout the tree).</li>
* </ul>
*
* @param catalog The catalog for which this reader is called.
* @param is The input stream that is to be read.
* @throws IOException if the URL cannot be read.
* @throws UnknownCatalogFormatException if the catalog format is
* not recognized.
* @throws UnparseableCatalogException if the catalog cannot be parsed.
* (For example, if it is supposed to be XML and isn't well-formed or
* if the parser class cannot be instantiated.)
*/
public void readCatalog(Catalog catalog, InputStream is)
throws IOException, CatalogException {
DocumentBuilderFactory factory = null;
DocumentBuilder builder = null;
factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
factory.setValidating(false);
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException pce) {
throw new CatalogException(CatalogException.UNPARSEABLE);
}
Document doc = null;
try {
doc = builder.parse(is);
} catch (SAXException se) {
throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
}
Element root = doc.getDocumentElement();
String namespaceURI = Namespaces.getNamespaceURI(root);
String localName = Namespaces.getLocalName(root);
String domParserClass = getCatalogParser(namespaceURI,
localName);
if (domParserClass == null) {
if (namespaceURI == null) {
catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
+ localName);
} else {
catalog.getCatalogManager().debug.message(1, "No Catalog parser for "
+ "{" + namespaceURI + "}"
+ localName);
}
return;
}
DOMCatalogParser domParser = null;
try {
domParser = (DOMCatalogParser) ReflectUtil.forName(domParserClass).newInstance();
} catch (ClassNotFoundException cnfe) {
catalog.getCatalogManager().debug.message(1, "Cannot load XML Catalog Parser class", domParserClass);
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (InstantiationException ie) {
catalog.getCatalogManager().debug.message(1, "Cannot instantiate XML Catalog Parser class", domParserClass);
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (IllegalAccessException iae) {
catalog.getCatalogManager().debug.message(1, "Cannot access XML Catalog Parser class", domParserClass);
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (ClassCastException cce ) {
catalog.getCatalogManager().debug.message(1, "Cannot cast XML Catalog Parser class", domParserClass);
throw new CatalogException(CatalogException.UNPARSEABLE);
}
Node node = root.getFirstChild();
while (node != null) {
domParser.parseCatalogEntry(catalog, node);
node = node.getNextSibling();
}
}
/**
* Read the catalog behind the specified URL.
*
* @see #readCatalog(Catalog, InputStream)
*
* @param catalog The catalog for which we are reading.
* @param fileUrl The URL of the document that should be read.
*
* @throws MalformedURLException if the specified URL cannot be
* turned into a URL object.
* @throws IOException if the URL cannot be read.
* @throws UnknownCatalogFormatException if the catalog format is
* not recognized.
* @throws UnparseableCatalogException if the catalog cannot be parsed.
* (For example, if it is supposed to be XML and isn't well-formed.)
*/
public void readCatalog(Catalog catalog, String fileUrl)
throws MalformedURLException, IOException, CatalogException {
URL url = new URL(fileUrl);
URLConnection urlCon = url.openConnection();
readCatalog(catalog, urlCon.getInputStream());
}
}

View File

@@ -0,0 +1,187 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// ExtendedXMLCatalogReader.java - Read XML Catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.util.Vector;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.Resolver;
import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import org.xml.sax.*;
import org.w3c.dom.*;
/**
* Parse Extended OASIS Entity Resolution Technical Committee
* XML Catalog files.
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class ExtendedXMLCatalogReader extends OASISXMLCatalogReader {
/** The namespace name of extended catalog elements */
public static final String extendedNamespaceName = "http://nwalsh.com/xcatalog/1.0";
/**
* The SAX <code>startElement</code> method recognizes elements
* from the plain catalog format and instantiates CatalogEntry
* objects for them.
*
* @param namespaceURI The namespace name of the element.
* @param localName The local name of the element.
* @param qName The QName of the element.
* @param atts The list of attributes on the element.
*
* @see CatalogEntry
*/
public void startElement (String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException {
// Check before calling the super because super will report our
// namespace as an extension namespace, but that doesn't count
// for this element.
boolean inExtension = inExtensionNamespace();
super.startElement(namespaceURI, localName, qName, atts);
int entryType = -1;
Vector entryArgs = new Vector();
if (namespaceURI != null && extendedNamespaceName.equals(namespaceURI)
&& !inExtension) {
// This is an Extended XML Catalog entry
if (atts.getValue("xml:base") != null) {
String baseURI = atts.getValue("xml:base");
entryType = Catalog.BASE;
entryArgs.add(baseURI);
baseURIStack.push(baseURI);
debug.message(4, "xml:base", baseURI);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (base)", localName);
}
}
entryType = -1;
entryArgs = new Vector();
} else {
baseURIStack.push(baseURIStack.peek());
}
if (localName.equals("uriSuffix")) {
if (checkAttributes(atts, "suffix", "uri")) {
entryType = Resolver.URISUFFIX;
entryArgs.add(atts.getValue("suffix"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "uriSuffix",
atts.getValue("suffix"),
atts.getValue("uri"));
}
} else if (localName.equals("systemSuffix")) {
if (checkAttributes(atts, "suffix", "uri")) {
entryType = Resolver.SYSTEMSUFFIX;
entryArgs.add(atts.getValue("suffix"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "systemSuffix",
atts.getValue("suffix"),
atts.getValue("uri"));
}
} else {
// This is equivalent to an invalid catalog entry type
debug.message(1, "Invalid catalog entry type", localName);
}
if (entryType >= 0) {
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry", localName);
}
}
}
}
}
/** The SAX <code>endElement</code> method does nothing. */
public void endElement (String namespaceURI,
String localName,
String qName)
throws SAXException {
super.endElement(namespaceURI, localName, qName);
// Check after popping the stack so we don't erroneously think we
// are our own extension namespace...
boolean inExtension = inExtensionNamespace();
int entryType = -1;
Vector entryArgs = new Vector();
if (namespaceURI != null
&& (extendedNamespaceName.equals(namespaceURI))
&& !inExtension) {
String popURI = (String) baseURIStack.pop();
String baseURI = (String) baseURIStack.peek();
if (!baseURI.equals(popURI)) {
entryType = catalog.BASE;
entryArgs.add(baseURI);
debug.message(4, "(reset) xml:base", baseURI);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (rbase)", localName);
}
}
}
}
}
}

View File

@@ -0,0 +1,541 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// OASISXMLCatalogReader.java - Read XML Catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.util.Stack;
import java.util.Vector;
import java.util.Enumeration;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
import org.xml.sax.*;
import org.w3c.dom.*;
/**
* Parse OASIS Entity Resolution Technical Committee
* XML Catalog files.
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class OASISXMLCatalogReader extends SAXCatalogReader implements SAXCatalogParser {
/** The catalog object needs to be stored by the object so that
* SAX callbacks can use it.
*/
protected Catalog catalog = null;
/** The namespace name of OASIS ERTC catalogs */
public static final String namespaceName = "urn:oasis:names:tc:entity:xmlns:xml:catalog";
/** The namespace name of OASIS ERTC TR9401 catalog extension */
public static final String tr9401NamespaceName = "urn:oasis:names:tc:entity:xmlns:tr9401:catalog";
protected Stack baseURIStack = new Stack();
protected Stack overrideStack = new Stack();
protected Stack namespaceStack = new Stack();
/** Set the current catalog. */
public void setCatalog (Catalog catalog) {
this.catalog = catalog;
debug = catalog.getCatalogManager().debug;
}
/** Get the current catalog. */
public Catalog getCatalog () {
return catalog;
}
/**
* Are we in an extension namespace?
*
* @return true if the current stack of open namespaces includes
* an extension namespace.
*/
protected boolean inExtensionNamespace() {
boolean inExtension = false;
Enumeration elements = namespaceStack.elements();
while (!inExtension && elements.hasMoreElements()) {
String ns = (String) elements.nextElement();
if (ns == null) {
inExtension = true;
} else {
inExtension = (!ns.equals(tr9401NamespaceName)
&& !ns.equals(namespaceName));
}
}
return inExtension;
}
// ----------------------------------------------------------------------
// Implement the SAX ContentHandler interface
/** The SAX <code>setDocumentLocator</code> method does nothing. */
public void setDocumentLocator (Locator locator) {
return;
}
/** The SAX <code>startDocument</code> method does nothing. */
public void startDocument ()
throws SAXException {
baseURIStack.push(catalog.getCurrentBase());
overrideStack.push(catalog.getDefaultOverride());
return;
}
/** The SAX <code>endDocument</code> method does nothing. */
public void endDocument ()
throws SAXException {
return;
}
/**
* The SAX <code>startElement</code> method recognizes elements
* from the plain catalog format and instantiates CatalogEntry
* objects for them.
*
* @param namespaceURI The namespace name of the element.
* @param localName The local name of the element.
* @param qName The QName of the element.
* @param atts The list of attributes on the element.
*
* @see CatalogEntry
*/
public void startElement (String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException {
int entryType = -1;
Vector entryArgs = new Vector();
namespaceStack.push(namespaceURI);
boolean inExtension = inExtensionNamespace();
if (namespaceURI != null && namespaceName.equals(namespaceURI)
&& !inExtension) {
// This is an XML Catalog entry
if (atts.getValue("xml:base") != null) {
String baseURI = atts.getValue("xml:base");
entryType = Catalog.BASE;
entryArgs.add(baseURI);
baseURIStack.push(baseURI);
debug.message(4, "xml:base", baseURI);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (base)", localName);
}
}
entryType = -1;
entryArgs = new Vector();
} else {
baseURIStack.push(baseURIStack.peek());
}
if ((localName.equals("catalog") || localName.equals("group"))
&& atts.getValue("prefer") != null) {
String override = atts.getValue("prefer");
if (override.equals("public")) {
override = "yes";
} else if (override.equals("system")) {
override = "no";
} else {
debug.message(1,
"Invalid prefer: must be 'system' or 'public'",
localName);
override = catalog.getDefaultOverride();
}
entryType = Catalog.OVERRIDE;
entryArgs.add(override);
overrideStack.push(override);
debug.message(4, "override", override);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (override)", localName);
}
}
entryType = -1;
entryArgs = new Vector();
} else {
overrideStack.push(overrideStack.peek());
}
if (localName.equals("delegatePublic")) {
if (checkAttributes(atts, "publicIdStartString", "catalog")) {
entryType = Catalog.DELEGATE_PUBLIC;
entryArgs.add(atts.getValue("publicIdStartString"));
entryArgs.add(atts.getValue("catalog"));
debug.message(4, "delegatePublic",
PublicId.normalize(atts.getValue("publicIdStartString")),
atts.getValue("catalog"));
}
} else if (localName.equals("delegateSystem")) {
if (checkAttributes(atts, "systemIdStartString", "catalog")) {
entryType = Catalog.DELEGATE_SYSTEM;
entryArgs.add(atts.getValue("systemIdStartString"));
entryArgs.add(atts.getValue("catalog"));
debug.message(4, "delegateSystem",
atts.getValue("systemIdStartString"),
atts.getValue("catalog"));
}
} else if (localName.equals("delegateURI")) {
if (checkAttributes(atts, "uriStartString", "catalog")) {
entryType = Catalog.DELEGATE_URI;
entryArgs.add(atts.getValue("uriStartString"));
entryArgs.add(atts.getValue("catalog"));
debug.message(4, "delegateURI",
atts.getValue("uriStartString"),
atts.getValue("catalog"));
}
} else if (localName.equals("rewriteSystem")) {
if (checkAttributes(atts, "systemIdStartString", "rewritePrefix")) {
entryType = Catalog.REWRITE_SYSTEM;
entryArgs.add(atts.getValue("systemIdStartString"));
entryArgs.add(atts.getValue("rewritePrefix"));
debug.message(4, "rewriteSystem",
atts.getValue("systemIdStartString"),
atts.getValue("rewritePrefix"));
}
} else if (localName.equals("systemSuffix")) {
if (checkAttributes(atts, "systemIdSuffix", "uri")) {
entryType = Catalog.SYSTEM_SUFFIX;
entryArgs.add(atts.getValue("systemIdSuffix"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "systemSuffix",
atts.getValue("systemIdSuffix"),
atts.getValue("uri"));
}
} else if (localName.equals("rewriteURI")) {
if (checkAttributes(atts, "uriStartString", "rewritePrefix")) {
entryType = Catalog.REWRITE_URI;
entryArgs.add(atts.getValue("uriStartString"));
entryArgs.add(atts.getValue("rewritePrefix"));
debug.message(4, "rewriteURI",
atts.getValue("uriStartString"),
atts.getValue("rewritePrefix"));
}
} else if (localName.equals("uriSuffix")) {
if (checkAttributes(atts, "uriSuffix", "uri")) {
entryType = Catalog.URI_SUFFIX;
entryArgs.add(atts.getValue("uriSuffix"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "uriSuffix",
atts.getValue("uriSuffix"),
atts.getValue("uri"));
}
} else if (localName.equals("nextCatalog")) {
if (checkAttributes(atts, "catalog")) {
entryType = Catalog.CATALOG;
entryArgs.add(atts.getValue("catalog"));
debug.message(4, "nextCatalog", atts.getValue("catalog"));
}
} else if (localName.equals("public")) {
if (checkAttributes(atts, "publicId", "uri")) {
entryType = Catalog.PUBLIC;
entryArgs.add(atts.getValue("publicId"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "public",
PublicId.normalize(atts.getValue("publicId")),
atts.getValue("uri"));
}
} else if (localName.equals("system")) {
if (checkAttributes(atts, "systemId", "uri")) {
entryType = Catalog.SYSTEM;
entryArgs.add(atts.getValue("systemId"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "system",
atts.getValue("systemId"),
atts.getValue("uri"));
}
} else if (localName.equals("uri")) {
if (checkAttributes(atts, "name", "uri")) {
entryType = Catalog.URI;
entryArgs.add(atts.getValue("name"));
entryArgs.add(atts.getValue("uri"));
debug.message(4, "uri",
atts.getValue("name"),
atts.getValue("uri"));
}
} else if (localName.equals("catalog")) {
// nop, start of catalog
} else if (localName.equals("group")) {
// nop, a group
} else {
// This is equivalent to an invalid catalog entry type
debug.message(1, "Invalid catalog entry type", localName);
}
if (entryType >= 0) {
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry", localName);
}
}
}
}
if (namespaceURI != null && tr9401NamespaceName.equals(namespaceURI)
&& !inExtension) {
// This is a TR9401 Catalog entry
if (atts.getValue("xml:base") != null) {
String baseURI = atts.getValue("xml:base");
entryType = Catalog.BASE;
entryArgs.add(baseURI);
baseURIStack.push(baseURI);
debug.message(4, "xml:base", baseURI);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (base)", localName);
}
}
entryType = -1;
entryArgs = new Vector();
} else {
baseURIStack.push(baseURIStack.peek());
}
if (localName.equals("doctype")) {
entryType = catalog.DOCTYPE;
entryArgs.add(atts.getValue("name"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("document")) {
entryType = catalog.DOCUMENT;
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("dtddecl")) {
entryType = catalog.DTDDECL;
entryArgs.add(atts.getValue("publicId"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("entity")) {
entryType = Catalog.ENTITY;
entryArgs.add(atts.getValue("name"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("linktype")) {
entryType = Catalog.LINKTYPE;
entryArgs.add(atts.getValue("name"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("notation")) {
entryType = Catalog.NOTATION;
entryArgs.add(atts.getValue("name"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("sgmldecl")) {
entryType = Catalog.SGMLDECL;
entryArgs.add(atts.getValue("uri"));
} else {
// This is equivalent to an invalid catalog entry type
debug.message(1, "Invalid catalog entry type", localName);
}
if (entryType >= 0) {
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry", localName);
}
}
}
}
}
public boolean checkAttributes (Attributes atts, String attName) {
if (atts.getValue(attName) == null) {
debug.message(1, "Error: required attribute " + attName + " missing.");
return false;
} else {
return true;
}
}
public boolean checkAttributes (Attributes atts,
String attName1,
String attName2) {
return checkAttributes(atts, attName1)
&& checkAttributes(atts, attName2);
}
/** The SAX <code>endElement</code> method does nothing. */
public void endElement (String namespaceURI,
String localName,
String qName)
throws SAXException {
int entryType = -1;
Vector entryArgs = new Vector();
boolean inExtension = inExtensionNamespace();
if (namespaceURI != null
&& !inExtension
&& (namespaceName.equals(namespaceURI)
|| tr9401NamespaceName.equals(namespaceURI))) {
String popURI = (String) baseURIStack.pop();
String baseURI = (String) baseURIStack.peek();
if (!baseURI.equals(popURI)) {
entryType = catalog.BASE;
entryArgs.add(baseURI);
debug.message(4, "(reset) xml:base", baseURI);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (rbase)", localName);
}
}
}
}
if (namespaceURI != null && namespaceName.equals(namespaceURI)
&& !inExtension) {
if (localName.equals("catalog") || localName.equals("group")) {
String popOverride = (String) overrideStack.pop();
String override = (String) overrideStack.peek();
if (!override.equals(popOverride)) {
entryType = catalog.OVERRIDE;
entryArgs.add(override);
overrideStack.push(override);
debug.message(4, "(reset) override", override);
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
debug.message(1, "Invalid catalog entry (roverride)", localName);
}
}
}
}
}
namespaceStack.pop();
return;
}
/** The SAX <code>characters</code> method does nothing. */
public void characters (char ch[], int start, int length)
throws SAXException {
return;
}
/** The SAX <code>ignorableWhitespace</code> method does nothing. */
public void ignorableWhitespace (char ch[], int start, int length)
throws SAXException {
return;
}
/** The SAX <code>processingInstruction</code> method does nothing. */
public void processingInstruction (String target, String data)
throws SAXException {
return;
}
/** The SAX <code>skippedEntity</code> method does nothing. */
public void skippedEntity (String name)
throws SAXException {
return;
}
/** The SAX <code>startPrefixMapping</code> method does nothing. */
public void startPrefixMapping(String prefix, String uri)
throws SAXException {
return;
}
/** The SAX <code>endPrefixMapping</code> method does nothing. */
public void endPrefixMapping(String prefix)
throws SAXException {
return;
}
}

View File

@@ -0,0 +1,45 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// SAXCatalogParser.java - An interface for reading catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import org.xml.sax.*;
/**
* The SAXCatalogParser interface.
*
* <p>This interface must be implemented in order for a class to
* participate as a parser for the SAXCatalogReader.
*
* @see Catalog
* @see SAXCatalogReader
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public interface SAXCatalogParser extends ContentHandler, DocumentHandler {
/** Set the Catalog for which parsing is being performed. */
public void setCatalog(Catalog catalog);
}

View File

@@ -0,0 +1,502 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// SAXCatalogReader.java - Read XML Catalog files
package com.sun.org.apache.xml.internal.resolver.readers;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.helpers.Debug;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.AttributeList;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.DocumentHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import sun.reflect.misc.ReflectUtil;
/**
* A SAX-based CatalogReader.
*
* <p>This class is used to read XML Catalogs using the SAX. This reader
* has an advantage over the DOM-based reader in that it functions on
* the stream of SAX events. It has the disadvantage
* that it cannot look around in the tree.</p>
*
* <p>Since the choice of CatalogReaders (in the InputStream case) can only
* be made on the basis of MIME type, the following problem occurs: only
* one CatalogReader can exist for all XML mime types. In order to get
* around this problem, the SAXCatalogReader relies on a set of external
* CatalogParsers to actually build the catalog.</p>
*
* <p>The selection of CatalogParsers is made on the basis of the QName
* of the root element of the document.</p>
*
* @see Catalog
* @see CatalogReader
* @see SAXCatalogReader
* @see TextCatalogReader
* @see DOMCatalogParser
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class SAXCatalogReader implements CatalogReader, ContentHandler, DocumentHandler {
/** The SAX Parser Factory */
protected SAXParserFactory parserFactory = null;
/** The SAX Parser Class */
protected String parserClass = null;
/**
* Mapping table from QNames to CatalogParser classes.
*
* <p>Each key in this hash table has the form "elementname"
* or "{namespaceuri}elementname". The former is used if the
* namespace URI is null.</p>
*/
protected Map<String, String> namespaceMap = new HashMap<>();
/** The parser in use for the current catalog. */
private SAXCatalogParser saxParser = null;
/** Set if something goes horribly wrong. It allows the class to
* ignore the rest of the events that are received.
*/
private boolean abandonHope = false;
/** The Catalog that we're working for. */
private Catalog catalog;
/** Set the XML SAX Parser Factory.
*/
public void setParserFactory(SAXParserFactory parserFactory) {
this.parserFactory = parserFactory;
}
/** Set the XML SAX Parser Class
*/
public void setParserClass(String parserClass) {
this.parserClass = parserClass;
}
/** Get the parser factory currently in use. */
public SAXParserFactory getParserFactory() {
return parserFactory;
}
/** Get the parser class currently in use. */
public String getParserClass() {
return parserClass;
}
/** The debug class to use for this reader.
*
* This is a bit of a hack. Anyway, whenever we read for a catalog,
* we extract the debug object
* from the catalog's manager so that we can use it to print messages.
*
* In production, we don't really expect any messages so it doesn't
* really matter. But it's still a bit of a hack.
*/
protected Debug debug = CatalogManager.getStaticManager().debug;
/** The constructor */
public SAXCatalogReader() {
parserFactory = null;
parserClass = null;
}
/** The constructor */
public SAXCatalogReader(SAXParserFactory parserFactory) {
this.parserFactory = parserFactory;
}
/** The constructor */
public SAXCatalogReader(String parserClass) {
this.parserClass = parserClass;
}
/** Set the SAXCatalogParser class for the given namespace/root
* element type.
*/
public void setCatalogParser(String namespaceURI,
String rootElement,
String parserClass) {
if (namespaceURI == null) {
namespaceMap.put(rootElement, parserClass);
} else {
namespaceMap.put("{"+namespaceURI+"}"+rootElement, parserClass);
}
}
/** Get the SAXCatalogParser class for the given namespace/root
* element type.
*/
public String getCatalogParser(String namespaceURI,
String rootElement) {
if (namespaceURI == null) {
return namespaceMap.get(rootElement);
} else {
return namespaceMap.get("{"+namespaceURI+"}"+rootElement);
}
}
/**
* Parse an XML Catalog file.
*
* @param catalog The catalog to which this catalog file belongs
* @param fileUrl The URL or filename of the catalog file to process
*
* @throws MalformedURLException Improper fileUrl
* @throws IOException Error reading catalog file
*/
public void readCatalog(Catalog catalog, String fileUrl)
throws MalformedURLException, IOException,
CatalogException {
URL url = null;
try {
url = new URL(fileUrl);
} catch (MalformedURLException e) {
url = new URL("file:///" + fileUrl);
}
debug = catalog.getCatalogManager().debug;
try {
URLConnection urlCon = url.openConnection();
readCatalog(catalog, urlCon.getInputStream());
} catch (FileNotFoundException e) {
catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found",
url.toString());
}
}
/**
* Parse an XML Catalog stream.
*
* @param catalog The catalog to which this catalog file belongs
* @param is The input stream from which the catalog will be read
*
* @throws MalformedURLException Improper fileUrl
* @throws IOException Error reading catalog file
* @throws CatalogException A Catalog exception
*/
public void readCatalog(Catalog catalog, InputStream is)
throws IOException, CatalogException {
// Create an instance of the parser
if (parserFactory == null && parserClass == null) {
debug.message(1, "Cannot read SAX catalog without a parser");
throw new CatalogException(CatalogException.UNPARSEABLE);
}
debug = catalog.getCatalogManager().debug;
EntityResolver bResolver = catalog.getCatalogManager().getBootstrapResolver();
this.catalog = catalog;
try {
if (parserFactory != null) {
SAXParser parser = parserFactory.newSAXParser();
SAXParserHandler spHandler = new SAXParserHandler();
spHandler.setContentHandler(this);
if (bResolver != null) {
spHandler.setEntityResolver(bResolver);
}
parser.parse(new InputSource(is), spHandler);
} else {
Parser parser = (Parser) ReflectUtil.forName(parserClass).newInstance();
parser.setDocumentHandler(this);
if (bResolver != null) {
parser.setEntityResolver(bResolver);
}
parser.parse(new InputSource(is));
}
} catch (ClassNotFoundException cnfe) {
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (IllegalAccessException iae) {
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (InstantiationException ie) {
throw new CatalogException(CatalogException.UNPARSEABLE);
} catch (ParserConfigurationException pce) {
throw new CatalogException(CatalogException.UNKNOWN_FORMAT);
} catch (SAXException se) {
Exception e = se.getException();
// FIXME: there must be a better way
UnknownHostException uhe = new UnknownHostException();
FileNotFoundException fnfe = new FileNotFoundException();
if (e != null) {
if (e.getClass() == uhe.getClass()) {
throw new CatalogException(CatalogException.PARSE_FAILED,
e.toString());
} else if (e.getClass() == fnfe.getClass()) {
throw new CatalogException(CatalogException.PARSE_FAILED,
e.toString());
}
}
throw new CatalogException(se);
}
}
// ----------------------------------------------------------------------
// Implement the SAX ContentHandler interface
/** The SAX <code>setDocumentLocator</code> method. Does nothing. */
public void setDocumentLocator (Locator locator) {
if (saxParser != null) {
saxParser.setDocumentLocator(locator);
}
}
/** The SAX <code>startDocument</code> method. Does nothing. */
public void startDocument () throws SAXException {
saxParser = null;
abandonHope = false;
return;
}
/** The SAX <code>endDocument</code> method. Does nothing. */
public void endDocument ()throws SAXException {
if (saxParser != null) {
saxParser.endDocument();
}
}
/**
* The SAX <code>startElement</code> method.
*
* <p>The catalog parser is selected based on the namespace of the
* first element encountered in the catalog.</p>
*/
public void startElement (String name,
AttributeList atts)
throws SAXException {
if (abandonHope) {
return;
}
if (saxParser == null) {
String prefix = "";
if (name.indexOf(':') > 0) {
prefix = name.substring(0, name.indexOf(':'));
}
String localName = name;
if (localName.indexOf(':') > 0) {
localName = localName.substring(localName.indexOf(':')+1);
}
String namespaceURI = null;
if (prefix.equals("")) {
namespaceURI = atts.getValue("xmlns");
} else {
namespaceURI = atts.getValue("xmlns:" + prefix);
}
String saxParserClass = getCatalogParser(namespaceURI,
localName);
if (saxParserClass == null) {
abandonHope = true;
if (namespaceURI == null) {
debug.message(2, "No Catalog parser for " + name);
} else {
debug.message(2, "No Catalog parser for "
+ "{" + namespaceURI + "}"
+ name);
}
return;
}
try {
saxParser = (SAXCatalogParser)
ReflectUtil.forName(saxParserClass).newInstance();
saxParser.setCatalog(catalog);
saxParser.startDocument();
saxParser.startElement(name, atts);
} catch (ClassNotFoundException cnfe) {
saxParser = null;
abandonHope = true;
debug.message(2, cnfe.toString());
} catch (InstantiationException ie) {
saxParser = null;
abandonHope = true;
debug.message(2, ie.toString());
} catch (IllegalAccessException iae) {
saxParser = null;
abandonHope = true;
debug.message(2, iae.toString());
} catch (ClassCastException cce ) {
saxParser = null;
abandonHope = true;
debug.message(2, cce.toString());
}
} else {
saxParser.startElement(name, atts);
}
}
/**
* The SAX2 <code>startElement</code> method.
*
* <p>The catalog parser is selected based on the namespace of the
* first element encountered in the catalog.</p>
*/
public void startElement (String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException {
if (abandonHope) {
return;
}
if (saxParser == null) {
String saxParserClass = getCatalogParser(namespaceURI,
localName);
if (saxParserClass == null) {
abandonHope = true;
if (namespaceURI == null) {
debug.message(2, "No Catalog parser for " + localName);
} else {
debug.message(2, "No Catalog parser for "
+ "{" + namespaceURI + "}"
+ localName);
}
return;
}
try {
saxParser = (SAXCatalogParser)
ReflectUtil.forName(saxParserClass).newInstance();
saxParser.setCatalog(catalog);
saxParser.startDocument();
saxParser.startElement(namespaceURI, localName, qName, atts);
} catch (ClassNotFoundException cnfe) {
saxParser = null;
abandonHope = true;
debug.message(2, cnfe.toString());
} catch (InstantiationException ie) {
saxParser = null;
abandonHope = true;
debug.message(2, ie.toString());
} catch (IllegalAccessException iae) {
saxParser = null;
abandonHope = true;
debug.message(2, iae.toString());
} catch (ClassCastException cce ) {
saxParser = null;
abandonHope = true;
debug.message(2, cce.toString());
}
} else {
saxParser.startElement(namespaceURI, localName, qName, atts);
}
}
/** The SAX <code>endElement</code> method. Does nothing. */
public void endElement (String name) throws SAXException {
if (saxParser != null) {
saxParser.endElement(name);
}
}
/** The SAX2 <code>endElement</code> method. Does nothing. */
public void endElement (String namespaceURI,
String localName,
String qName) throws SAXException {
if (saxParser != null) {
saxParser.endElement(namespaceURI, localName, qName);
}
}
/** The SAX <code>characters</code> method. Does nothing. */
public void characters (char ch[], int start, int length)
throws SAXException {
if (saxParser != null) {
saxParser.characters(ch, start, length);
}
}
/** The SAX <code>ignorableWhitespace</code> method. Does nothing. */
public void ignorableWhitespace (char ch[], int start, int length)
throws SAXException {
if (saxParser != null) {
saxParser.ignorableWhitespace(ch, start, length);
}
}
/** The SAX <code>processingInstruction</code> method. Does nothing. */
public void processingInstruction (String target, String data)
throws SAXException {
if (saxParser != null) {
saxParser.processingInstruction(target, data);
}
}
/** The SAX <code>startPrefixMapping</code> method. Does nothing. */
public void startPrefixMapping (String prefix, String uri)
throws SAXException {
if (saxParser != null) {
saxParser.startPrefixMapping (prefix, uri);
}
}
/** The SAX <code>endPrefixMapping</code> method. Does nothing. */
public void endPrefixMapping (String prefix)
throws SAXException {
if (saxParser != null) {
saxParser.endPrefixMapping (prefix);
}
}
/** The SAX <code>skippedentity</code> method. Does nothing. */
public void skippedEntity (String name)
throws SAXException {
if (saxParser != null) {
saxParser.skippedEntity(name);
}
}
}

View File

@@ -0,0 +1,150 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// SAXParserHandler.java - An entity-resolving DefaultHandler
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.io.IOException;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
/**
* An entity-resolving DefaultHandler.
*
* <p>This class provides a SAXParser DefaultHandler that performs
* entity resolution.
* </p>
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*/
public class SAXParserHandler extends DefaultHandler {
private EntityResolver er = null;
private ContentHandler ch = null;
public SAXParserHandler() {
super();
}
public void setEntityResolver(EntityResolver er) {
this.er = er;
}
public void setContentHandler(ContentHandler ch) {
this.ch = ch;
}
// Entity Resolver
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException {
if (er != null) {
try {
return er.resolveEntity(publicId, systemId);
} catch (IOException e) {
System.out.println("resolveEntity threw IOException!");
return null;
}
} else {
return null;
}
}
// Content Handler
public void characters(char[] ch, int start, int length)
throws SAXException {
if (this.ch != null) {
this.ch.characters(ch, start, length);
}
}
public void endDocument()
throws SAXException {
if (ch != null) {
ch.endDocument();
}
}
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
if (ch != null) {
ch.endElement(namespaceURI, localName, qName);
}
}
public void endPrefixMapping(String prefix)
throws SAXException {
if (ch != null) {
ch.endPrefixMapping(prefix);
}
}
public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException {
if (this.ch != null) {
this.ch.ignorableWhitespace(ch, start, length);
}
}
public void processingInstruction(String target, String data)
throws SAXException {
if (ch != null) {
ch.processingInstruction(target, data);
}
}
public void setDocumentLocator(Locator locator) {
if (ch != null) {
ch.setDocumentLocator(locator);
}
}
public void skippedEntity(String name)
throws SAXException {
if (ch != null) {
ch.skippedEntity(name);
}
}
public void startDocument()
throws SAXException {
if (ch != null) {
ch.startDocument();
}
}
public void startElement(String namespaceURI, String localName,
String qName, Attributes atts)
throws SAXException {
if (ch != null) {
ch.startElement(namespaceURI, localName, qName, atts);
}
}
public void startPrefixMapping(String prefix, String uri)
throws SAXException {
if (ch != null) {
ch.startPrefixMapping(prefix, uri);
}
}
}

View File

@@ -0,0 +1,143 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// TR9401CatalogReader.java - Read OASIS Catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.io.InputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Vector;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
/**
* Parses OASIS Open Catalog files.
*
* <p>This class reads OASIS Open Catalog files, returning a stream
* of tokens.</p>
*
* <p>This code interrogates the following non-standard system properties:</p>
*
* <dl>
* <dt><b>xml.catalog.debug</b></dt>
* <dd><p>Sets the debug level. A value of 0 is assumed if the
* property is not set or is not a number.</p></dd>
* </dl>
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class TR9401CatalogReader extends TextCatalogReader {
/**
* Start parsing an OASIS TR9401 Open Catalog file. The file is
* actually read and parsed
* as needed by <code>nextEntry</code>.
*
* <p>In a TR9401 Catalog the 'DELEGATE' entry delegates public
* identifiers. There is no delegate entry for system identifiers
* or URIs.</p>
*
* @param catalog The Catalog to populate
* @param is The input stream from which to read the TR9401 Catalog
*
* @throws MalformedURLException Improper fileUrl
* @throws IOException Error reading catalog file
*/
public void readCatalog(Catalog catalog, InputStream is)
throws MalformedURLException, IOException {
catfile = is;
if (catfile == null) {
return;
}
Vector unknownEntry = null;
try {
while (true) {
String token = nextToken();
if (token == null) {
if (unknownEntry != null) {
catalog.unknownEntry(unknownEntry);
unknownEntry = null;
}
catfile.close();
catfile = null;
return;
}
String entryToken = null;
if (caseSensitive) {
entryToken = token;
} else {
entryToken = token.toUpperCase();
}
if (entryToken.equals("DELEGATE")) {
entryToken = "DELEGATE_PUBLIC";
}
try {
int type = CatalogEntry.getEntryType(entryToken);
int numArgs = CatalogEntry.getEntryArgCount(type);
Vector args = new Vector();
if (unknownEntry != null) {
catalog.unknownEntry(unknownEntry);
unknownEntry = null;
}
for (int count = 0; count < numArgs; count++) {
args.addElement(nextToken());
}
catalog.addEntry(new CatalogEntry(entryToken, args));
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
if (unknownEntry == null) {
unknownEntry = new Vector();
}
unknownEntry.addElement(token);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token);
unknownEntry = null;
} else if (cex.getExceptionType() == CatalogException.UNENDED_COMMENT) {
catalog.getCatalogManager().debug.message(1, cex.getMessage());
}
}
}
} catch (CatalogException cex2) {
if (cex2.getExceptionType() == CatalogException.UNENDED_COMMENT) {
catalog.getCatalogManager().debug.message(1, cex2.getMessage());
}
}
}
}

View File

@@ -0,0 +1,303 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// TextCatalogReader.java - Read text/plain Catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.util.Vector;
import java.util.Stack;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import com.sun.org.apache.xml.internal.resolver.readers.CatalogReader;
/**
* Parses plain text Catalog files.
*
* <p>This class reads plain text Open Catalog files.</p>
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class TextCatalogReader implements CatalogReader {
/** The input stream used to read the catalog */
protected InputStream catfile = null;
/**
* Character lookahead stack. Reading a catalog sometimes requires
* up to two characters of lookahead.
*/
protected int[] stack = new int[3];
/**
* Token stack. Recognizing an unexpected catalog entry requires
* the ability to "push back" a token.
*/
protected Stack tokenStack = new Stack();
/** The current position on the lookahead stack */
protected int top = -1;
/** Are keywords in the catalog case sensitive? */
protected boolean caseSensitive = false;
/**
* Construct a CatalogReader object.
*/
public TextCatalogReader() { }
public void setCaseSensitive(boolean isCaseSensitive) {
caseSensitive = isCaseSensitive;
}
public boolean getCaseSensitive() {
return caseSensitive;
}
/**
* Start parsing a text catalog file. The file is
* actually read and parsed
* as needed by <code>nextEntry</code>.</p>
*
* @param fileUrl The URL or filename of the catalog file to process
*
* @throws MalformedURLException Improper fileUrl
* @throws IOException Error reading catalog file
*/
public void readCatalog(Catalog catalog, String fileUrl)
throws MalformedURLException, IOException {
URL catURL = null;
try {
catURL = new URL(fileUrl);
} catch (MalformedURLException e) {
catURL = new URL("file:///" + fileUrl);
}
URLConnection urlCon = catURL.openConnection();
try {
readCatalog(catalog, urlCon.getInputStream());
} catch (FileNotFoundException e) {
catalog.getCatalogManager().debug.message(1, "Failed to load catalog, file not found",
catURL.toString());
}
}
public void readCatalog(Catalog catalog, InputStream is)
throws MalformedURLException, IOException {
catfile = is;
if (catfile == null) {
return;
}
Vector unknownEntry = null;
try {
while (true) {
String token = nextToken();
if (token == null) {
if (unknownEntry != null) {
catalog.unknownEntry(unknownEntry);
unknownEntry = null;
}
catfile.close();
catfile = null;
return;
}
String entryToken = null;
if (caseSensitive) {
entryToken = token;
} else {
entryToken = token.toUpperCase();
}
try {
int type = CatalogEntry.getEntryType(entryToken);
int numArgs = CatalogEntry.getEntryArgCount(type);
Vector args = new Vector();
if (unknownEntry != null) {
catalog.unknownEntry(unknownEntry);
unknownEntry = null;
}
for (int count = 0; count < numArgs; count++) {
args.addElement(nextToken());
}
catalog.addEntry(new CatalogEntry(entryToken, args));
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
if (unknownEntry == null) {
unknownEntry = new Vector();
}
unknownEntry.addElement(token);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", token);
unknownEntry = null;
} else if (cex.getExceptionType() == CatalogException.UNENDED_COMMENT) {
catalog.getCatalogManager().debug.message(1, cex.getMessage());
}
}
}
} catch (CatalogException cex2) {
if (cex2.getExceptionType() == CatalogException.UNENDED_COMMENT) {
catalog.getCatalogManager().debug.message(1, cex2.getMessage());
}
}
}
/**
* The destructor.
*
* <p>Makes sure the catalog file is closed.</p>
*/
protected void finalize() {
if (catfile != null) {
try {
catfile.close();
} catch (IOException e) {
// whatever...
}
}
catfile = null;
}
// -----------------------------------------------------------------
/**
* Return the next token in the catalog file.
*
* <p>FYI: This code does not throw any sort of exception for
* a file that contains an n
*
* @return The Catalog file token from the input stream.
* @throws IOException If an error occurs reading from the stream.
*/
protected String nextToken() throws IOException, CatalogException {
String token = "";
int ch, nextch;
if (!tokenStack.empty()) {
return (String) tokenStack.pop();
}
// Skip over leading whitespace and comments
while (true) {
// skip leading whitespace
ch = catfile.read();
while (ch <= ' ') { // all ctrls are whitespace
ch = catfile.read();
if (ch < 0) {
return null;
}
}
// now 'ch' is the current char from the file
nextch = catfile.read();
if (nextch < 0) {
return null;
}
if (ch == '-' && nextch == '-') {
// we've found a comment, skip it...
ch = ' ';
nextch = nextChar();
while ((ch != '-' || nextch != '-') && nextch > 0) {
ch = nextch;
nextch = nextChar();
}
if (nextch < 0) {
throw new CatalogException(CatalogException.UNENDED_COMMENT,
"Unterminated comment in catalog file; EOF treated as end-of-comment.");
}
// Ok, we've found the end of the comment,
// loop back to the top and start again...
} else {
stack[++top] = nextch;
stack[++top] = ch;
break;
}
}
ch = nextChar();
if (ch == '"' || ch == '\'') {
int quote = ch;
while ((ch = nextChar()) != quote) {
char[] chararr = new char[1];
chararr[0] = (char) ch;
String s = new String(chararr);
token = token.concat(s);
}
return token;
} else {
// return the next whitespace or comment delimited
// string
while (ch > ' ') {
nextch = nextChar();
if (ch == '-' && nextch == '-') {
stack[++top] = ch;
stack[++top] = nextch;
return token;
} else {
char[] chararr = new char[1];
chararr[0] = (char) ch;
String s = new String(chararr);
token = token.concat(s);
ch = nextch;
}
}
return token;
}
}
/**
* Return the next logical character from the input stream.
*
* @return The next (logical) character from the input stream. The
* character may be buffered from a previous lookahead.
*
* @throws IOException If an error occurs reading from the stream.
*/
protected int nextChar() throws IOException {
if (top < 0) {
return catfile.read();
} else {
return stack[top--];
}
}
}

View File

@@ -0,0 +1,188 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// XCatalogReader.java - Read XML Catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
import java.util.Vector;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
import org.xml.sax.*;
import javax.xml.parsers.*;
/**
* Parse "xcatalog" XML Catalog files, this is the XML Catalog format
* developed by John Cowan and supported by Apache.
*
* @see Catalog
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
*/
public class XCatalogReader extends SAXCatalogReader implements SAXCatalogParser {
/** The catalog object needs to be stored by the object so that
* SAX callbacks can use it.
*/
protected Catalog catalog = null;
/** Set the current catalog. */
public void setCatalog (Catalog catalog) {
this.catalog = catalog;
}
/** Get the current catalog. */
public Catalog getCatalog () {
return catalog;
}
/** The constructor */
public XCatalogReader(SAXParserFactory parserFactory) {
super(parserFactory);
}
// ----------------------------------------------------------------------
// Implement the SAX DocumentHandler interface
/** The SAX <code>setDocumentLocator</code> method does nothing. */
public void setDocumentLocator (Locator locator) {
return;
}
/** The SAX <code>startDocument</code> method does nothing. */
public void startDocument ()
throws SAXException {
return;
}
/** The SAX <code>endDocument</code> method does nothing. */
public void endDocument ()
throws SAXException {
return;
}
/**
* The SAX <code>startElement</code> method recognizes elements
* from the plain catalog format and instantiates CatalogEntry
* objects for them.
*
* @param namespaceURI The namespace name of the element.
* @param localName The local name of the element.
* @param qName The QName of the element.
* @param atts The list of attributes on the element.
*
* @see CatalogEntry
*/
public void startElement (String namespaceURI,
String localName,
String qName,
Attributes atts)
throws SAXException {
int entryType = -1;
Vector entryArgs = new Vector();
if (localName.equals("Base")) {
entryType = catalog.BASE;
entryArgs.add(atts.getValue("HRef"));
catalog.getCatalogManager().debug.message(4, "Base", atts.getValue("HRef"));
} else if (localName.equals("Delegate")) {
entryType = catalog.DELEGATE_PUBLIC;
entryArgs.add(atts.getValue("PublicId"));
entryArgs.add(atts.getValue("HRef"));
catalog.getCatalogManager().debug.message(4, "Delegate",
PublicId.normalize(atts.getValue("PublicId")),
atts.getValue("HRef"));
} else if (localName.equals("Extend")) {
entryType = catalog.CATALOG;
entryArgs.add(atts.getValue("HRef"));
catalog.getCatalogManager().debug.message(4, "Extend", atts.getValue("HRef"));
} else if (localName.equals("Map")) {
entryType = catalog.PUBLIC;
entryArgs.add(atts.getValue("PublicId"));
entryArgs.add(atts.getValue("HRef"));
catalog.getCatalogManager().debug.message(4, "Map",
PublicId.normalize(atts.getValue("PublicId")),
atts.getValue("HRef"));
} else if (localName.equals("Remap")) {
entryType = catalog.SYSTEM;
entryArgs.add(atts.getValue("SystemId"));
entryArgs.add(atts.getValue("HRef"));
catalog.getCatalogManager().debug.message(4, "Remap",
atts.getValue("SystemId"),
atts.getValue("HRef"));
} else if (localName.equals("XMLCatalog")) {
// nop, start of catalog
} else {
// This is equivalent to an invalid catalog entry type
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
}
if (entryType >= 0) {
try {
CatalogEntry ce = new CatalogEntry(entryType, entryArgs);
catalog.addEntry(ce);
} catch (CatalogException cex) {
if (cex.getExceptionType() == CatalogException.INVALID_ENTRY_TYPE) {
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry type", localName);
} else if (cex.getExceptionType() == CatalogException.INVALID_ENTRY) {
catalog.getCatalogManager().debug.message(1, "Invalid catalog entry", localName);
}
}
}
}
/** The SAX <code>endElement</code> method does nothing. */
public void endElement (String namespaceURI,
String localName,
String qName)
throws SAXException {
return;
}
/** The SAX <code>characters</code> method does nothing. */
public void characters (char ch[], int start, int length)
throws SAXException {
return;
}
/** The SAX <code>ignorableWhitespace</code> method does nothing. */
public void ignorableWhitespace (char ch[], int start, int length)
throws SAXException {
return;
}
/** The SAX <code>processingInstruction</code> method does nothing. */
public void processingInstruction (String target, String data)
throws SAXException {
return;
}
}

View File

@@ -0,0 +1,345 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// CatalogResolver.java - A SAX EntityResolver/JAXP URI Resolver
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.tools;
import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.MalformedURLException;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.EntityResolver;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.Source;
import javax.xml.transform.URIResolver;
import javax.xml.transform.TransformerException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;
import jdk.xml.internal.JdkXmlUtils;
/**
* A SAX EntityResolver/JAXP URIResolver that uses catalogs.
*
* <p>This class implements both a SAX EntityResolver and a JAXP URIResolver.
* </p>
*
* <p>This resolver understands OASIS TR9401 catalogs, XCatalogs, and the
* current working draft of the OASIS Entity Resolution Technical
* Committee specification.</p>
*
* @see Catalog
* @see org.xml.sax.EntityResolver
* @see javax.xml.transform.URIResolver
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public class CatalogResolver implements EntityResolver, URIResolver {
/** Make the parser Namespace aware? */
public boolean namespaceAware = true;
/** Make the parser validating? */
public boolean validating = false;
/** The underlying catalog */
private Catalog catalog = null;
/** The catalog manager */
private CatalogManager catalogManager = CatalogManager.getStaticManager();
/** Constructor */
public CatalogResolver() {
initializeCatalogs(false);
}
/** Constructor */
public CatalogResolver(boolean privateCatalog) {
initializeCatalogs(privateCatalog);
}
/** Constructor */
public CatalogResolver(CatalogManager manager) {
catalogManager = manager;
initializeCatalogs(!catalogManager.getUseStaticCatalog());
}
/** Initialize catalog */
private void initializeCatalogs(boolean privateCatalog) {
catalog = catalogManager.getCatalog();
}
/** Return the underlying catalog */
public Catalog getCatalog() {
return catalog;
}
/**
* Implements the guts of the <code>resolveEntity</code> method
* for the SAX interface.
*
* <p>Presented with an optional public identifier and a system
* identifier, this function attempts to locate a mapping in the
* catalogs.</p>
*
* <p>If such a mapping is found, it is returned. If no mapping is
* found, null is returned.</p>
*
* @param publicId The public identifier for the entity in question.
* This may be null.
*
* @param systemId The system identifier for the entity in question.
* XML requires a system identifier on all external entities, so this
* value is always specified.
*
* @return The resolved identifier (a URI reference).
*/
public String getResolvedEntity (String publicId, String systemId) {
String resolved = null;
if (catalog == null) {
catalogManager.debug.message(1, "Catalog resolution attempted with null catalog; ignored");
return null;
}
if (systemId != null) {
try {
resolved = catalog.resolveSystem(systemId);
} catch (MalformedURLException me) {
catalogManager.debug.message(1, "Malformed URL exception trying to resolve",
publicId);
resolved = null;
} catch (IOException ie) {
catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
resolved = null;
}
}
if (resolved == null) {
if (publicId != null) {
try {
resolved = catalog.resolvePublic(publicId, systemId);
} catch (MalformedURLException me) {
catalogManager.debug.message(1, "Malformed URL exception trying to resolve",
publicId);
} catch (IOException ie) {
catalogManager.debug.message(1, "I/O exception trying to resolve", publicId);
}
}
if (resolved != null) {
catalogManager.debug.message(2, "Resolved public", publicId, resolved);
}
} else {
catalogManager.debug.message(2, "Resolved system", systemId, resolved);
}
return resolved;
}
/**
* Implements the <code>resolveEntity</code> method
* for the SAX interface.
*
* <p>Presented with an optional public identifier and a system
* identifier, this function attempts to locate a mapping in the
* catalogs.</p>
*
* <p>If such a mapping is found, the resolver attempts to open
* the mapped value as an InputSource and return it. Exceptions are
* ignored and null is returned if the mapped value cannot be opened
* as an input source.</p>
*
* <p>If no mapping is found (or an error occurs attempting to open
* the mapped value as an input source), null is returned and the system
* will use the specified system identifier as if no entityResolver
* was specified.</p>
*
* @param publicId The public identifier for the entity in question.
* This may be null.
*
* @param systemId The system identifier for the entity in question.
* XML requires a system identifier on all external entities, so this
* value is always specified.
*
* @return An InputSource for the mapped identifier, or null.
*/
public InputSource resolveEntity (String publicId, String systemId) {
String resolved = getResolvedEntity(publicId, systemId);
if (resolved != null) {
try {
InputSource iSource = new InputSource(resolved);
iSource.setPublicId(publicId);
// Ideally this method would not attempt to open the
// InputStream, but there is a bug (in Xerces, at least)
// that causes the parser to mistakenly open the wrong
// system identifier if the returned InputSource does
// not have a byteStream.
//
// It could be argued that we still shouldn't do this here,
// but since the purpose of calling the entityResolver is
// almost certainly to open the input stream, it seems to
// do little harm.
//
URL url = new URL(resolved);
InputStream iStream = url.openStream();
iSource.setByteStream(iStream);
return iSource;
} catch (Exception e) {
catalogManager.debug.message(1, "Failed to create InputSource", resolved);
return null;
}
}
return null;
}
/** JAXP URIResolver API */
public Source resolve(String href, String base)
throws TransformerException {
String uri = href;
String fragment = null;
int hashPos = href.indexOf("#");
if (hashPos >= 0) {
uri = href.substring(0, hashPos);
fragment = href.substring(hashPos+1);
}
String result = null;
try {
result = catalog.resolveURI(href);
} catch (Exception e) {
// nop;
}
if (result == null) {
try {
URL url = null;
if (base==null) {
url = new URL(uri);
result = url.toString();
} else {
URL baseURL = new URL(base);
url = (href.length()==0 ? baseURL : new URL(baseURL, uri));
result = url.toString();
}
} catch (java.net.MalformedURLException mue) {
// try to make an absolute URI from the current base
String absBase = makeAbsolute(base);
if (!absBase.equals(base)) {
// don't bother if the absBase isn't different!
return resolve(href, absBase);
} else {
throw new TransformerException("Malformed URL "
+ href + "(base " + base + ")",
mue);
}
}
}
catalogManager.debug.message(2, "Resolved URI", href, result);
SAXSource source = new SAXSource();
source.setInputSource(new InputSource(result));
setEntityResolver(source);
return source;
}
/**
* <p>Establish an entityResolver for newly resolved URIs.</p>
*
* <p>This is called from the URIResolver to set an EntityResolver
* on the SAX parser to be used for new XML documents that are
* encountered as a result of the document() function, xsl:import,
* or xsl:include. This is done because the XSLT processor calls
* out to the SAXParserFactory itself to create a new SAXParser to
* parse the new document. The new parser does not automatically
* inherit the EntityResolver of the original (although arguably
* it should). See below:</p>
*
* <tt>"If an application wants to set the ErrorHandler or
* EntityResolver for an XMLReader used during a transformation,
* it should use a URIResolver to return the SAXSource which
* provides (with getXMLReader) a reference to the XMLReader"</tt>
*
* <p>...quoted from page 118 of the Java API for XML
* Processing 1.1 specification</p>
*
*/
private void setEntityResolver(SAXSource source) throws TransformerException {
XMLReader reader = source.getXMLReader();
if (reader == null) {
SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser());
try {
reader = spf.newSAXParser().getXMLReader();
}
catch (ParserConfigurationException ex) {
throw new TransformerException(ex);
}
catch (SAXException ex) {
throw new TransformerException(ex);
}
}
reader.setEntityResolver(this);
source.setXMLReader(reader);
}
/** Attempt to construct an absolute URI */
private String makeAbsolute(String uri) {
if (uri == null) {
uri = "";
}
try {
URL url = new URL(uri);
return url.toString();
} catch (MalformedURLException mue) {
try {
URL fileURL = FileURL.makeURL(uri);
return fileURL.toString();
} catch (MalformedURLException mue2) {
// bail
return uri;
}
}
}
}

View File

@@ -0,0 +1,447 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// ResolvingParser.java - An interface for reading catalog files
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.tools;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.Locale;
import org.xml.sax.Parser;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.ErrorHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.DocumentHandler;
import org.xml.sax.AttributeList;
import org.xml.sax.EntityResolver;
import org.xml.sax.SAXException;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;
import jdk.xml.internal.JdkXmlUtils;
/**
* A SAX Parser that performs catalog-based entity resolution.
*
* <p>This class implements a SAX Parser that performs entity resolution
* using the CatalogResolver. The actual, underlying parser is obtained
* from a SAXParserFactory.</p>
* </p>
*
* @deprecated This interface has been replaced by the
* {@link com.sun.org.apache.xml.internal.resolver.tools.ResolvingXMLReader} for SAX2.
* @see CatalogResolver
* @see org.xml.sax.Parser
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public class ResolvingParser
implements Parser, DTDHandler, DocumentHandler, EntityResolver {
/** Make the parser Namespace aware? */
public static boolean namespaceAware = true;
/** Make the parser validating? */
public static boolean validating = false;
/** Suppress explanatory message?
*
* @see #parse(InputSource)
*/
public static boolean suppressExplanation = false;
/** The underlying parser. */
private SAXParser saxParser = null;
/** The underlying reader. */
private Parser parser = null;
/** The underlying DocumentHandler. */
private DocumentHandler documentHandler = null;
/** The underlying DTDHandler. */
private DTDHandler dtdHandler = null;
/** The manager for the underlying resolver. */
private CatalogManager catalogManager = CatalogManager.getStaticManager();
/** The underlying catalog resolver. */
private CatalogResolver catalogResolver = null;
/** A separate resolver for oasis-xml-pi catalogs. */
private CatalogResolver piCatalogResolver = null;
/** Are we in the prolog? Is an oasis-xml-catalog PI valid now? */
private boolean allowXMLCatalogPI = false;
/** Has an oasis-xml-catalog PI been seen? */
private boolean oasisXMLCatalogPI = false;
/** The base URI of the input document, if known. */
private URL baseURL = null;
/** Constructor. */
public ResolvingParser() {
initParser();
}
/** Constructor. */
public ResolvingParser(CatalogManager manager) {
catalogManager = manager;
initParser();
}
/** Initialize the parser. */
private void initParser() {
catalogResolver = new CatalogResolver(catalogManager);
SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser());
spf.setValidating(validating);
try {
saxParser = spf.newSAXParser();
parser = saxParser.getParser();
documentHandler = null;
dtdHandler = null;
} catch (Exception ex) {
ex.printStackTrace();
}
}
/** Return the Catalog being used. */
public Catalog getCatalog() {
return catalogResolver.getCatalog();
}
/**
* SAX Parser API.
*
* <p>Note that the JAXP 1.1ea2 parser crashes with an InternalError if
* it encounters a system identifier that appears to be a relative URI
* that begins with a slash. For example, the declaration:</p>
*
* <pre>
* &lt;!DOCTYPE book SYSTEM "/path/to/dtd/on/my/system/docbookx.dtd">
* </pre>
*
* <p>would cause such an error. As a convenience, this method catches
* that error and prints an explanation. (Unfortunately, it's not possible
* to identify the particular system identifier that causes the problem.)
* </p>
*
* <p>The underlying error is forwarded after printing the explanatory
* message. The message is only every printed once and if
* <code>suppressExplanation</code> is set to <code>false</code> before
* parsing, it will never be printed.</p>
*/
public void parse(InputSource input)
throws IOException,
SAXException {
setupParse(input.getSystemId());
try {
parser.parse(input);
} catch (InternalError ie) {
explain(input.getSystemId());
throw ie;
}
}
/** SAX Parser API.
*
* @see #parse(InputSource)
*/
public void parse(String systemId)
throws IOException,
SAXException {
setupParse(systemId);
try {
parser.parse(systemId);
} catch (InternalError ie) {
explain(systemId);
throw ie;
}
}
/** SAX Parser API. */
public void setDocumentHandler(DocumentHandler handler) {
documentHandler = handler;
}
/** SAX Parser API. */
public void setDTDHandler(DTDHandler handler) {
dtdHandler = handler;
}
/**
* SAX Parser API.
*
* <p>The purpose of this class is to implement an entity resolver.
* Attempting to set a different one is pointless (and ignored).</p>
*/
public void setEntityResolver(EntityResolver resolver) {
// nop
}
/** SAX Parser API. */
public void setErrorHandler(ErrorHandler handler) {
parser.setErrorHandler(handler);
}
/** SAX Parser API. */
public void setLocale(Locale locale) throws SAXException {
parser.setLocale(locale);
}
/** SAX DocumentHandler API. */
public void characters(char[] ch, int start, int length)
throws SAXException {
if (documentHandler != null) {
documentHandler.characters(ch,start,length);
}
}
/** SAX DocumentHandler API. */
public void endDocument() throws SAXException {
if (documentHandler != null) {
documentHandler.endDocument();
}
}
/** SAX DocumentHandler API. */
public void endElement(String name) throws SAXException {
if (documentHandler != null) {
documentHandler.endElement(name);
}
}
/** SAX DocumentHandler API. */
public void ignorableWhitespace(char[] ch, int start, int length)
throws SAXException {
if (documentHandler != null) {
documentHandler.ignorableWhitespace(ch,start,length);
}
}
/** SAX DocumentHandler API. */
public void processingInstruction(String target, String pidata)
throws SAXException {
if (target.equals("oasis-xml-catalog")) {
URL catalog = null;
String data = pidata;
int pos = data.indexOf("catalog=");
if (pos >= 0) {
data = data.substring(pos+8);
if (data.length() > 1) {
String quote = data.substring(0,1);
data = data.substring(1);
pos = data.indexOf(quote);
if (pos >= 0) {
data = data.substring(0, pos);
try {
if (baseURL != null) {
catalog = new URL(baseURL, data);
} else {
catalog = new URL(data);
}
} catch (MalformedURLException mue) {
// nevermind
}
}
}
}
if (allowXMLCatalogPI) {
if (catalogManager.getAllowOasisXMLCatalogPI()) {
catalogManager.debug.message(4,"oasis-xml-catalog PI", pidata);
if (catalog != null) {
try {
catalogManager.debug.message(4,"oasis-xml-catalog", catalog.toString());
oasisXMLCatalogPI = true;
if (piCatalogResolver == null) {
piCatalogResolver = new CatalogResolver(true);
}
piCatalogResolver.getCatalog().parseCatalog(catalog.toString());
} catch (Exception e) {
catalogManager.debug.message(3, "Exception parsing oasis-xml-catalog: "
+ catalog.toString());
}
} else {
catalogManager.debug.message(3, "PI oasis-xml-catalog unparseable: " + pidata);
}
} else {
catalogManager.debug.message(4,"PI oasis-xml-catalog ignored: " + pidata);
}
} else {
catalogManager.debug.message(3, "PI oasis-xml-catalog occurred in an invalid place: "
+ pidata);
}
} else {
if (documentHandler != null) {
documentHandler.processingInstruction(target, pidata);
}
}
}
/** SAX DocumentHandler API. */
public void setDocumentLocator(Locator locator) {
if (documentHandler != null) {
documentHandler.setDocumentLocator(locator);
}
}
/** SAX DocumentHandler API. */
public void startDocument() throws SAXException {
if (documentHandler != null) {
documentHandler.startDocument();
}
}
/** SAX DocumentHandler API. */
public void startElement(String name, AttributeList atts)
throws SAXException {
allowXMLCatalogPI = false;
if (documentHandler != null) {
documentHandler.startElement(name,atts);
}
}
/** SAX DTDHandler API. */
public void notationDecl (String name, String publicId, String systemId)
throws SAXException {
allowXMLCatalogPI = false;
if (dtdHandler != null) {
dtdHandler.notationDecl(name,publicId,systemId);
}
}
/** SAX DTDHandler API. */
public void unparsedEntityDecl (String name,
String publicId,
String systemId,
String notationName)
throws SAXException {
allowXMLCatalogPI = false;
if (dtdHandler != null) {
dtdHandler.unparsedEntityDecl (name, publicId, systemId, notationName);
}
}
/**
* Implements the <code>resolveEntity</code> method
* for the SAX interface, using an underlying CatalogResolver
* to do the real work.
*/
public InputSource resolveEntity (String publicId, String systemId) {
allowXMLCatalogPI = false;
String resolved = catalogResolver.getResolvedEntity(publicId, systemId);
if (resolved == null && piCatalogResolver != null) {
resolved = piCatalogResolver.getResolvedEntity(publicId, systemId);
}
if (resolved != null) {
try {
InputSource iSource = new InputSource(resolved);
iSource.setPublicId(publicId);
// Ideally this method would not attempt to open the
// InputStream, but there is a bug (in Xerces, at least)
// that causes the parser to mistakenly open the wrong
// system identifier if the returned InputSource does
// not have a byteStream.
//
// It could be argued that we still shouldn't do this here,
// but since the purpose of calling the entityResolver is
// almost certainly to open the input stream, it seems to
// do little harm.
//
URL url = new URL(resolved);
InputStream iStream = url.openStream();
iSource.setByteStream(iStream);
return iSource;
} catch (Exception e) {
catalogManager.debug.message(1, "Failed to create InputSource", resolved);
return null;
}
} else {
return null;
}
}
/** Setup for parsing. */
private void setupParse(String systemId) {
allowXMLCatalogPI = true;
parser.setEntityResolver(this);
parser.setDocumentHandler(this);
parser.setDTDHandler(this);
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
/** Provide one possible explanation for an InternalError. */
private void explain(String systemId) {
if (!suppressExplanation) {
System.out.println("Parser probably encountered bad URI in " + systemId);
System.out.println("For example, replace '/some/uri' with 'file:/some/uri'.");
}
}
}

View File

@@ -0,0 +1,353 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// ResolvingXMLFilter.java - An XMLFilter that performs catalog resolution
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.tools;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.XMLFilterImpl;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.helpers.FileURL;
/**
* A SAX XMLFilter that performs catalog-based entity resolution.
*
* <p>This class implements a SAX XMLFilter that performs entity resolution
* using the CatalogResolver. The actual, underlying parser is obtained
* from a SAXParserFactory.</p>
* </p>
*
* @see CatalogResolver
* @see org.xml.sax.XMLFilter
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public class ResolvingXMLFilter extends XMLFilterImpl {
/**
* Suppress explanatory message?
*
* @see #parse(InputSource)
*/
public static boolean suppressExplanation = false;
/** The manager for the underlying resolver. */
CatalogManager catalogManager = CatalogManager.getStaticManager();
/** The underlying catalog resolver. */
private CatalogResolver catalogResolver = null;
/** A separate resolver for oasis-xml-pi catalogs. */
private CatalogResolver piCatalogResolver = null;
/** Are we in the prolog? Is an oasis-xml-catalog PI valid now? */
private boolean allowXMLCatalogPI = false;
/** Has an oasis-xml-catalog PI been seen? */
private boolean oasisXMLCatalogPI = false;
/** The base URI of the input document, if known. */
private URL baseURL = null;
/** Construct an empty XML Filter with no parent. */
public ResolvingXMLFilter() {
super();
catalogResolver = new CatalogResolver(catalogManager);
}
/** Construct an XML filter with the specified parent. */
public ResolvingXMLFilter(XMLReader parent) {
super(parent);
catalogResolver = new CatalogResolver(catalogManager);
}
/** Construct an XML filter with the specified parent. */
public ResolvingXMLFilter(CatalogManager manager) {
super();
catalogManager = manager;
catalogResolver = new CatalogResolver(catalogManager);
}
/** Construct an XML filter with the specified parent. */
public ResolvingXMLFilter(XMLReader parent, CatalogManager manager) {
super(parent);
catalogManager = manager;
catalogResolver = new CatalogResolver(catalogManager);
}
/**
* Provide accessto the underlying Catalog.
*/
public Catalog getCatalog() {
return catalogResolver.getCatalog();
}
/**
* SAX XMLReader API.
*
* <p>Note that the JAXP 1.1ea2 parser crashes with an InternalError if
* it encounters a system identifier that appears to be a relative URI
* that begins with a slash. For example, the declaration:</p>
*
* <pre>
* &lt;!DOCTYPE book SYSTEM "/path/to/dtd/on/my/system/docbookx.dtd">
* </pre>
*
* <p>would cause such an error. As a convenience, this method catches
* that error and prints an explanation. (Unfortunately, it's not possible
* to identify the particular system identifier that causes the problem.)
* </p>
*
* <p>The underlying error is forwarded after printing the explanatory
* message. The message is only every printed once and if
* <code>suppressExplanation</code> is set to <code>false</code> before
* parsing, it will never be printed.</p>
*/
public void parse(InputSource input)
throws IOException, SAXException {
allowXMLCatalogPI = true;
setupBaseURI(input.getSystemId());
try {
super.parse(input);
} catch (InternalError ie) {
explain(input.getSystemId());
throw ie;
}
}
/** SAX XMLReader API.
*
* @see #parse(InputSource)
*/
public void parse(String systemId)
throws IOException, SAXException {
allowXMLCatalogPI = true;
setupBaseURI(systemId);
try {
super.parse(systemId);
} catch (InternalError ie) {
explain(systemId);
throw ie;
}
}
/**
* Implements the <code>resolveEntity</code> method
* for the SAX interface, using an underlying CatalogResolver
* to do the real work.
*/
public InputSource resolveEntity (String publicId, String systemId) {
allowXMLCatalogPI = false;
String resolved = catalogResolver.getResolvedEntity(publicId, systemId);
if (resolved == null && piCatalogResolver != null) {
resolved = piCatalogResolver.getResolvedEntity(publicId, systemId);
}
if (resolved != null) {
try {
InputSource iSource = new InputSource(resolved);
iSource.setPublicId(publicId);
// Ideally this method would not attempt to open the
// InputStream, but there is a bug (in Xerces, at least)
// that causes the parser to mistakenly open the wrong
// system identifier if the returned InputSource does
// not have a byteStream.
//
// It could be argued that we still shouldn't do this here,
// but since the purpose of calling the entityResolver is
// almost certainly to open the input stream, it seems to
// do little harm.
//
URL url = new URL(resolved);
InputStream iStream = url.openStream();
iSource.setByteStream(iStream);
return iSource;
} catch (Exception e) {
catalogManager.debug.message(1, "Failed to create InputSource", resolved);
return null;
}
} else {
return null;
}
}
/** SAX DTDHandler API.
*
* <p>Captured here only to detect the end of the prolog so that
* we can ignore subsequent oasis-xml-catalog PIs. Otherwise
* the events are just passed through.</p>
*/
public void notationDecl (String name, String publicId, String systemId)
throws SAXException {
allowXMLCatalogPI = false;
super.notationDecl(name,publicId,systemId);
}
/** SAX DTDHandler API.
*
* <p>Captured here only to detect the end of the prolog so that
* we can ignore subsequent oasis-xml-catalog PIs. Otherwise
* the events are just passed through.</p>
*/
public void unparsedEntityDecl (String name,
String publicId,
String systemId,
String notationName)
throws SAXException {
allowXMLCatalogPI = false;
super.unparsedEntityDecl (name, publicId, systemId, notationName);
}
/** SAX ContentHandler API.
*
* <p>Captured here only to detect the end of the prolog so that
* we can ignore subsequent oasis-xml-catalog PIs. Otherwise
* the events are just passed through.</p>
*/
public void startElement (String uri, String localName, String qName,
Attributes atts)
throws SAXException {
allowXMLCatalogPI = false;
super.startElement(uri,localName,qName,atts);
}
/** SAX ContentHandler API.
*
* <p>Detect and use the oasis-xml-catalog PI if it occurs.</p>
*/
public void processingInstruction(String target, String pidata)
throws SAXException {
if (target.equals("oasis-xml-catalog")) {
URL catalog = null;
String data = pidata;
int pos = data.indexOf("catalog=");
if (pos >= 0) {
data = data.substring(pos+8);
if (data.length() > 1) {
String quote = data.substring(0,1);
data = data.substring(1);
pos = data.indexOf(quote);
if (pos >= 0) {
data = data.substring(0, pos);
try {
if (baseURL != null) {
catalog = new URL(baseURL, data);
} else {
catalog = new URL(data);
}
} catch (MalformedURLException mue) {
// nevermind
}
}
}
}
if (allowXMLCatalogPI) {
if (catalogManager.getAllowOasisXMLCatalogPI()) {
catalogManager.debug.message(4,"oasis-xml-catalog PI", pidata);
if (catalog != null) {
try {
catalogManager.debug.message(4,"oasis-xml-catalog", catalog.toString());
oasisXMLCatalogPI = true;
if (piCatalogResolver == null) {
piCatalogResolver = new CatalogResolver(true);
}
piCatalogResolver.getCatalog().parseCatalog(catalog.toString());
} catch (Exception e) {
catalogManager.debug.message(3, "Exception parsing oasis-xml-catalog: "
+ catalog.toString());
}
} else {
catalogManager.debug.message(3, "PI oasis-xml-catalog unparseable: " + pidata);
}
} else {
catalogManager.debug.message(4,"PI oasis-xml-catalog ignored: " + pidata);
}
} else {
catalogManager.debug.message(3, "PI oasis-xml-catalog occurred in an invalid place: "
+ pidata);
}
} else {
super.processingInstruction(target, pidata);
}
}
/** Save the base URI of the document being parsed. */
private void setupBaseURI(String systemId) {
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
/** Provide one possible explanation for an InternalError. */
private void explain(String systemId) {
if (!suppressExplanation) {
System.out.println("XMLReader probably encountered bad URI in " + systemId);
System.out.println("For example, replace '/some/uri' with 'file:/some/uri'.");
}
suppressExplanation = true;
}
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
// ResolvingXMLReader.java - An XMLReader that performs catalog resolution
/*
* Copyright 2001-2004 The Apache Software Foundation or its licensors,
* as applicable.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.tools;
import org.xml.sax.*;
import javax.xml.parsers.*;
import com.sun.org.apache.xml.internal.resolver.*;
import jdk.xml.internal.JdkXmlUtils;
/**
* A SAX XMLReader that performs catalog-based entity resolution.
*
* <p>This class implements a SAX XMLReader that performs entity resolution
* using the CatalogResolver. The actual, underlying parser is obtained
* from a SAXParserFactory.</p>
* </p>
*
* @see CatalogResolver
* @see org.xml.sax.XMLReader
*
* @author Norman Walsh
* <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a>
*
* @version 1.0
*/
public class ResolvingXMLReader extends ResolvingXMLFilter {
/** Make the parser Namespace aware? */
public static boolean namespaceAware = true;
/** Make the parser validating? */
public static boolean validating = false;
/**
* Construct a new reader from the JAXP factory.
*
* <p>In order to do its job, a ResolvingXMLReader must in fact be
* a filter. So the only difference between this code and the filter
* code is that the constructor builds a new reader.</p>
*/
public ResolvingXMLReader() {
super();
SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser());
spf.setValidating(validating);
try {
SAXParser parser = spf.newSAXParser();
setParent(parser.getXMLReader());
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* Construct a new reader from the JAXP factory.
*
* <p>In order to do its job, a ResolvingXMLReader must in fact be
* a filter. So the only difference between this code and the filter
* code is that the constructor builds a new reader.</p>
*/
public ResolvingXMLReader(CatalogManager manager) {
super(manager);
SAXParserFactory spf = JdkXmlUtils.getSAXFactory(catalogManager.overrideDefaultParser());
spf.setValidating(validating);
try {
SAXParser parser = spf.newSAXParser();
setParent(parser.getXMLReader());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@@ -0,0 +1,343 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver;
import com.sun.org.apache.xml.internal.security.transforms.Transform;
import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
import com.sun.org.apache.xml.internal.security.utils.I18n;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/**
* This class does the configuration of the library. This includes creating
* the mapping of Canonicalization and Transform algorithms. Initialization is
* done by calling {@link Init#init} which should be done in any static block
* of the files of this library. We ensure that this call is only executed once.
*/
public class Init {
/** The namespace for CONF file **/
public static final String CONF_NS = "http://www.xmlsecurity.org/NS/#configuration";
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(Init.class);
/** Field alreadyInitialized */
private static boolean alreadyInitialized = false;
/**
* Method isInitialized
* @return true if the library is already initialized.
*/
public static final synchronized boolean isInitialized() {
return Init.alreadyInitialized;
}
/**
* Method init
*
*/
public static synchronized void init() {
if (alreadyInitialized) {
return;
}
InputStream is =
AccessController.doPrivileged(
(PrivilegedAction<InputStream>)
() -> {
String cfile =
System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
if (cfile == null) {
return null;
}
return Init.class.getResourceAsStream(cfile);
}
);
if (is == null) {
dynamicInit();
} else {
fileInit(is);
}
alreadyInitialized = true;
}
/**
* Dynamically initialise the library by registering the default algorithms/implementations
*/
private static void dynamicInit() {
//
// Load the Resource Bundle - the default is the English resource bundle.
// To load another resource bundle, call I18n.init(...) before calling this
// method.
//
I18n.init("en", "US");
LOG.debug("Registering default algorithms");
try {
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>(){
@Override public Void run() throws XMLSecurityException {
//
// Bind the default prefixes
//
ElementProxy.registerDefaultPrefixes();
//
// Set the default Transforms
//
Transform.registerDefaultAlgorithms();
//
// Set the default signature algorithms
//
SignatureAlgorithm.registerDefaultAlgorithms();
//
// Set the default JCE algorithms
//
JCEMapper.registerDefaultAlgorithms();
//
// Set the default c14n algorithms
//
Canonicalizer.registerDefaultAlgorithms();
//
// Register the default resolvers
//
ResourceResolver.registerDefaultResolvers();
//
// Register the default key resolvers
//
KeyResolver.registerDefaultResolvers();
return null;
}
});
} catch (PrivilegedActionException ex) {
XMLSecurityException xse = (XMLSecurityException)ex.getException();
LOG.error(xse.getMessage(), xse);
xse.printStackTrace();
}
}
/**
* Initialise the library from a configuration file
*/
private static void fileInit(InputStream is) {
try {
/* read library configuration file */
DocumentBuilder db = XMLUtils.createDocumentBuilder(false);
Document doc = db.parse(is);
Node config = doc.getFirstChild();
for (; config != null; config = config.getNextSibling()) {
if ("Configuration".equals(config.getLocalName())) {
break;
}
}
if (config == null) {
LOG.error("Error in reading configuration file - Configuration element not found");
return;
}
for (Node el = config.getFirstChild(); el != null; el = el.getNextSibling()) {
if (Node.ELEMENT_NODE != el.getNodeType()) {
continue;
}
String tag = el.getLocalName();
if ("ResourceBundles".equals(tag)) {
Element resource = (Element)el;
/* configure internationalization */
Attr langAttr = resource.getAttributeNodeNS(null, "defaultLanguageCode");
Attr countryAttr = resource.getAttributeNodeNS(null, "defaultCountryCode");
String languageCode =
(langAttr == null) ? null : langAttr.getNodeValue();
String countryCode =
(countryAttr == null) ? null : countryAttr.getNodeValue();
I18n.init(languageCode, countryCode);
}
if ("CanonicalizationMethods".equals(tag)) {
Element[] list =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "CanonicalizationMethod");
for (Element element : list) {
String uri = element.getAttributeNS(null, "URI");
String javaClass =
element.getAttributeNS(null, "JAVACLASS");
try {
Canonicalizer.register(uri, javaClass);
LOG.debug("Canonicalizer.register({}, {})", uri, javaClass);
} catch (ClassNotFoundException e) {
Object exArgs[] = { uri, javaClass };
LOG.error(I18n.translate("algorithm.classDoesNotExist", exArgs));
}
}
}
if ("TransformAlgorithms".equals(tag)) {
Element[] tranElem =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "TransformAlgorithm");
for (Element element : tranElem) {
String uri = element.getAttributeNS(null, "URI");
String javaClass =
element.getAttributeNS(null, "JAVACLASS");
try {
Transform.register(uri, javaClass);
LOG.debug("Transform.register({}, {})", uri, javaClass);
} catch (ClassNotFoundException e) {
Object exArgs[] = { uri, javaClass };
LOG.error(I18n.translate("algorithm.classDoesNotExist", exArgs));
} catch (NoClassDefFoundError ex) {
LOG.warn("Not able to found dependencies for algorithm, I'll keep working.");
}
}
}
if ("JCEAlgorithmMappings".equals(tag)) {
Node algorithmsNode = ((Element)el).getElementsByTagName("Algorithms").item(0);
if (algorithmsNode != null) {
Element[] algorithms =
XMLUtils.selectNodes(algorithmsNode.getFirstChild(), CONF_NS, "Algorithm");
for (Element element : algorithms) {
String id = element.getAttributeNS(null, "URI");
JCEMapper.register(id, new JCEMapper.Algorithm(element));
}
}
}
if ("SignatureAlgorithms".equals(tag)) {
Element[] sigElems =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "SignatureAlgorithm");
for (Element sigElem : sigElems) {
String uri = sigElem.getAttributeNS(null, "URI");
String javaClass =
sigElem.getAttributeNS(null, "JAVACLASS");
/** $todo$ handle registering */
try {
SignatureAlgorithm.register(uri, javaClass);
LOG.debug("SignatureAlgorithm.register({}, {})", uri, javaClass);
} catch (ClassNotFoundException e) {
Object exArgs[] = { uri, javaClass };
LOG.error(I18n.translate("algorithm.classDoesNotExist", exArgs));
}
}
}
if ("ResourceResolvers".equals(tag)) {
Element[] resolverElem =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
for (Element element : resolverElem) {
String javaClass =
element.getAttributeNS(null, "JAVACLASS");
String description =
element.getAttributeNS(null, "DESCRIPTION");
if (description != null && description.length() > 0) {
LOG.debug("Register Resolver: {}: {}", javaClass, description);
} else {
LOG.debug("Register Resolver: {}: For unknown purposes", javaClass);
}
try {
ResourceResolver.register(javaClass);
} catch (Throwable e) {
LOG.warn(
"Cannot register:" + javaClass
+ " perhaps some needed jars are not installed",
e
);
}
}
}
if ("KeyResolver".equals(tag)){
Element[] resolverElem =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
List<String> classNames = new ArrayList<>(resolverElem.length);
for (Element element : resolverElem) {
String javaClass =
element.getAttributeNS(null, "JAVACLASS");
String description =
element.getAttributeNS(null, "DESCRIPTION");
if (description != null && description.length() > 0) {
LOG.debug("Register Resolver: {}: {}", javaClass, description);
} else {
LOG.debug("Register Resolver: {}: For unknown purposes", javaClass);
}
classNames.add(javaClass);
}
KeyResolver.registerClassNames(classNames);
}
if ("PrefixMappings".equals(tag)){
LOG.debug("Now I try to bind prefixes:");
Element[] nl =
XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "PrefixMapping");
for (Element element : nl) {
String namespace = element.getAttributeNS(null, "namespace");
String prefix = element.getAttributeNS(null, "prefix");
LOG.debug("Now I try to bind {} to {}", prefix, namespace);
ElementProxy.setDefaultPrefix(namespace, prefix);
}
}
}
} catch (Exception e) {
LOG.error("Bad: ", e);
}
}
}

View File

@@ -0,0 +1,76 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* The Algorithm class which stores the Algorithm URI as a string.
*/
public abstract class Algorithm extends SignatureElementProxy {
/**
*
* @param doc
* @param algorithmURI is the URI of the algorithm as String
*/
public Algorithm(Document doc, String algorithmURI) {
super(doc);
this.setAlgorithmURI(algorithmURI);
}
/**
* Constructor Algorithm
*
* @param element
* @param baseURI
* @throws XMLSecurityException
*/
public Algorithm(Element element, String baseURI) throws XMLSecurityException {
super(element, baseURI);
}
/**
* Method getAlgorithmURI
*
* @return The URI of the algorithm
*/
public String getAlgorithmURI() {
return getLocalAttribute(Constants._ATT_ALGORITHM);
}
/**
* Sets the algorithm's URI as used in the signature.
*
* @param algorithmURI is the URI of the algorithm as String
*/
protected void setAlgorithmURI(String algorithmURI) {
if (algorithmURI != null) {
setLocalAttribute(Constants._ATT_ALGORITHM, algorithmURI);
}
}
}

View File

@@ -0,0 +1,84 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
// NOTE! This is a duplicate of utils.ClassLoaderUtils with public
// modifiers changed to package-private. Make sure to integrate any future
// changes to utils.ClassLoaderUtils to this file.
final class ClassLoaderUtils {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(ClassLoaderUtils.class);
private ClassLoaderUtils() {
}
/**
* Load a class with a given name. <p></p> It will try to load the class in the
* following order:
* <ul>
* <li>From Thread.currentThread().getContextClassLoader()
* <li>Using the basic Class.forName()
* <li>From ClassLoaderUtil.class.getClassLoader()
* <li>From the callingClass.getClassLoader()
* </ul>
*
* @param className The name of the class to load
* @param callingClass The Class object of the calling object
* @throws ClassNotFoundException If the class cannot be found anywhere.
*/
static Class<?> loadClass(String className, Class<?> callingClass)
throws ClassNotFoundException {
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl != null) {
return cl.loadClass(className);
}
} catch (ClassNotFoundException e) {
LOG.debug(e.getMessage(), e);
//ignore
}
return loadClass2(className, callingClass);
}
private static Class<?> loadClass2(String className, Class<?> callingClass)
throws ClassNotFoundException {
try {
return Class.forName(className);
} catch (ClassNotFoundException ex) {
try {
if (ClassLoaderUtils.class.getClassLoader() != null) {
return ClassLoaderUtils.class.getClassLoader().loadClass(className);
}
} catch (ClassNotFoundException exc) {
if (callingClass != null && callingClass.getClassLoader() != null) {
return callingClass.getClassLoader().loadClass(className);
}
}
LOG.debug(ex.getMessage(), ex);
throw ex;
}
}
}

View File

@@ -0,0 +1,373 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
import org.w3c.dom.Element;
/**
* This class maps algorithm identifier URIs to JAVA JCE class names.
*/
public class JCEMapper {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(JCEMapper.class);
private static Map<String, Algorithm> algorithmsMap =
new ConcurrentHashMap<String, Algorithm>();
private static String providerName;
/**
* Method register
*
* @param id
* @param algorithm
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to register the JCE algorithm
*/
public static void register(String id, Algorithm algorithm) {
JavaUtils.checkRegisterPermission();
algorithmsMap.put(id, algorithm);
}
/**
* This method registers the default algorithms.
*/
public static void registerDefaultAlgorithms() {
// Digest algorithms
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5,
new Algorithm("", "MD5", "MessageDigest")
);
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160,
new Algorithm("", "RIPEMD160", "MessageDigest")
);
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1,
new Algorithm("", "SHA-1", "MessageDigest")
);
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA224,
new Algorithm("", "SHA-224", "MessageDigest")
);
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256,
new Algorithm("", "SHA-256", "MessageDigest")
);
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA384,
new Algorithm("", "SHA-384", "MessageDigest")
);
algorithmsMap.put(
MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512,
new Algorithm("", "SHA-512", "MessageDigest")
);
// Signature algorithms
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_DSA,
new Algorithm("DSA", "SHA1withDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256,
new Algorithm("DSA", "SHA256withDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5,
new Algorithm("RSA", "MD5withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160,
new Algorithm("RSA", "RIPEMD160withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1,
new Algorithm("RSA", "SHA1withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224,
new Algorithm("RSA", "SHA224withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256,
new Algorithm("RSA", "SHA256withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384,
new Algorithm("RSA", "SHA384withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512,
new Algorithm("RSA", "SHA512withRSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1_MGF1,
new Algorithm("RSA", "SHA1withRSAandMGF1", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224_MGF1,
new Algorithm("RSA", "SHA224withRSAandMGF1", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256_MGF1,
new Algorithm("RSA", "SHA256withRSAandMGF1", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384_MGF1,
new Algorithm("RSA", "SHA384withRSAandMGF1", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512_MGF1,
new Algorithm("RSA", "SHA512withRSAandMGF1", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1,
new Algorithm("EC", "SHA1withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA224,
new Algorithm("EC", "SHA224withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256,
new Algorithm("EC", "SHA256withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384,
new Algorithm("EC", "SHA384withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512,
new Algorithm("EC", "SHA512withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_RIPEMD160,
new Algorithm("EC", "RIPEMD160withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5,
new Algorithm("", "HmacMD5", "Mac", 0, 0)
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160,
new Algorithm("", "HMACRIPEMD160", "Mac", 0, 0)
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
new Algorithm("", "HmacSHA1", "Mac", 0, 0)
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA224,
new Algorithm("", "HmacSHA224", "Mac", 0, 0)
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA256,
new Algorithm("", "HmacSHA256", "Mac", 0, 0)
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA384,
new Algorithm("", "HmacSHA384", "Mac", 0, 0)
);
algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA512,
new Algorithm("", "HmacSHA512", "Mac", 0, 0)
);
}
/**
* Method translateURItoJCEID
*
* @param algorithmURI
* @return the JCE standard name corresponding to the given URI
*/
public static String translateURItoJCEID(String algorithmURI) {
Algorithm algorithm = getAlgorithm(algorithmURI);
if (algorithm != null) {
return algorithm.jceName;
}
return null;
}
/**
* Method getAlgorithmClassFromURI
* @param algorithmURI
* @return the class name that implements this algorithm
*/
public static String getAlgorithmClassFromURI(String algorithmURI) {
Algorithm algorithm = getAlgorithm(algorithmURI);
if (algorithm != null) {
return algorithm.algorithmClass;
}
return null;
}
/**
* Returns the keylength in bits for a particular algorithm.
*
* @param algorithmURI
* @return The length of the key used in the algorithm
*/
public static int getKeyLengthFromURI(String algorithmURI) {
Algorithm algorithm = getAlgorithm(algorithmURI);
if (algorithm != null) {
return algorithm.keyLength;
}
return 0;
}
public static int getIVLengthFromURI(String algorithmURI) {
Algorithm algorithm = getAlgorithm(algorithmURI);
if (algorithm != null) {
return algorithm.ivLength;
}
return 0;
}
/**
* Method getJCEKeyAlgorithmFromURI
*
* @param algorithmURI
* @return The KeyAlgorithm for the given URI.
*/
public static String getJCEKeyAlgorithmFromURI(String algorithmURI) {
Algorithm algorithm = getAlgorithm(algorithmURI);
if (algorithm != null) {
return algorithm.requiredKey;
}
return null;
}
/**
* Method getJCEProviderFromURI
*
* @param algorithmURI
* @return The JCEProvider for the given URI.
*/
public static String getJCEProviderFromURI(String algorithmURI) {
Algorithm algorithm = getAlgorithm(algorithmURI);
if (algorithm != null) {
return algorithm.jceProvider;
}
return null;
}
/**
* Method getAlgorithm
*
* @param algorithmURI
* @return The Algorithm object for the given URI.
*/
private static Algorithm getAlgorithm(String algorithmURI) {
LOG.debug("Request for URI {}", algorithmURI);
if (algorithmURI != null) {
return algorithmsMap.get(algorithmURI);
}
return null;
}
/**
* Gets the default Provider for obtaining the security algorithms
* @return the default providerId.
*/
public static String getProviderId() {
return providerName;
}
/**
* Sets the default Provider for obtaining the security algorithms
* @param provider the default providerId.
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to register the JCE algorithm
*/
public static void setProviderId(String provider) {
JavaUtils.checkRegisterPermission();
providerName = provider;
}
/**
* Represents the Algorithm xml element
*/
public static class Algorithm {
final String requiredKey;
final String jceName;
final String algorithmClass;
final int keyLength;
final int ivLength;
final String jceProvider;
/**
* Gets data from element
* @param el
*/
public Algorithm(Element el) {
requiredKey = el.getAttributeNS(null, "RequiredKey");
jceName = el.getAttributeNS(null, "JCEName");
algorithmClass = el.getAttributeNS(null, "AlgorithmClass");
jceProvider = el.getAttributeNS(null, "JCEProvider");
if (el.hasAttribute("KeyLength")) {
keyLength = Integer.parseInt(el.getAttributeNS(null, "KeyLength"));
} else {
keyLength = 0;
}
if (el.hasAttribute("IVLength")) {
ivLength = Integer.parseInt(el.getAttributeNS(null, "IVLength"));
} else {
ivLength = 0;
}
}
public Algorithm(String requiredKey, String jceName) {
this(requiredKey, jceName, null, 0, 0);
}
public Algorithm(String requiredKey, String jceName, String algorithmClass) {
this(requiredKey, jceName, algorithmClass, 0, 0);
}
public Algorithm(String requiredKey, String jceName, int keyLength) {
this(requiredKey, jceName, null, keyLength, 0);
}
public Algorithm(String requiredKey, String jceName, String algorithmClass, int keyLength, int ivLength) {
this(requiredKey, jceName, algorithmClass, keyLength, ivLength, null);
}
public Algorithm(String requiredKey, String jceName,
String algorithmClass, int keyLength, int ivLength, String jceProvider) {
this.requiredKey = requiredKey;
this.jceName = jceName;
this.algorithmClass = algorithmClass;
this.keyLength = keyLength;
this.ivLength = ivLength;
this.jceProvider = jceProvider;
}
}
}

View File

@@ -0,0 +1,258 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import java.security.MessageDigest;
import java.security.NoSuchProviderException;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.EncryptionConstants;
import org.w3c.dom.Document;
/**
* Digest Message wrapper and selector class.
*
* <pre>
* MessageDigestAlgorithm.getInstance()
* </pre>
*/
public class MessageDigestAlgorithm extends Algorithm {
/** Message Digest - NOT RECOMMENDED MD5*/
public static final String ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5 =
Constants.MoreAlgorithmsSpecNS + "md5";
/** Digest - Required SHA1*/
public static final String ALGO_ID_DIGEST_SHA1 = Constants.SignatureSpecNS + "sha1";
/** Message Digest - OPTIONAL SHA224*/
public static final String ALGO_ID_DIGEST_SHA224 =
Constants.MoreAlgorithmsSpecNS + "sha224";
/** Message Digest - RECOMMENDED SHA256*/
public static final String ALGO_ID_DIGEST_SHA256 =
EncryptionConstants.EncryptionSpecNS + "sha256";
/** Message Digest - OPTIONAL SHA384*/
public static final String ALGO_ID_DIGEST_SHA384 =
Constants.MoreAlgorithmsSpecNS + "sha384";
/** Message Digest - OPTIONAL SHA512*/
public static final String ALGO_ID_DIGEST_SHA512 =
EncryptionConstants.EncryptionSpecNS + "sha512";
/** Message Digest - OPTIONAL RIPEMD-160*/
public static final String ALGO_ID_DIGEST_RIPEMD160 =
EncryptionConstants.EncryptionSpecNS + "ripemd160";
/** Field algorithm stores the actual {@link java.security.MessageDigest} */
private final MessageDigest algorithm;
/**
* Constructor for the brave who pass their own message digest algorithms and the
* corresponding URI.
* @param doc
* @param algorithmURI
*/
private MessageDigestAlgorithm(Document doc, String algorithmURI)
throws XMLSignatureException {
super(doc, algorithmURI);
algorithm = getDigestInstance(algorithmURI);
}
/**
* Factory method for constructing a message digest algorithm by name.
*
* @param doc
* @param algorithmURI
* @return The MessageDigestAlgorithm element to attach in document and to digest
* @throws XMLSignatureException
*/
public static MessageDigestAlgorithm getInstance(
Document doc, String algorithmURI
) throws XMLSignatureException {
return new MessageDigestAlgorithm(doc, algorithmURI);
}
private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
if (algorithmID == null) {
Object[] exArgs = { algorithmURI };
throw new XMLSignatureException("algorithms.NoSuchMap", exArgs);
}
MessageDigest md;
String provider = JCEMapper.getProviderId();
try {
if (provider == null) {
md = MessageDigest.getInstance(algorithmID);
} else {
md = MessageDigest.getInstance(algorithmID, provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
return md;
}
/**
* Returns the actual {@link java.security.MessageDigest} algorithm object
*
* @return the actual {@link java.security.MessageDigest} algorithm object
*/
public MessageDigest getAlgorithm() {
return algorithm;
}
/**
* Proxy method for {@link java.security.MessageDigest#isEqual}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param digesta
* @param digestb
* @return the result of the {@link java.security.MessageDigest#isEqual} method
*/
public static boolean isEqual(byte[] digesta, byte[] digestb) {
return MessageDigest.isEqual(digesta, digestb);
}
/**
* Proxy method for {@link java.security.MessageDigest#digest()}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @return the result of the {@link java.security.MessageDigest#digest()} method
*/
public byte[] digest() {
return algorithm.digest();
}
/**
* Proxy method for {@link java.security.MessageDigest#digest(byte[])}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param input
* @return the result of the {@link java.security.MessageDigest#digest(byte[])} method
*/
public byte[] digest(byte input[]) {
return algorithm.digest(input);
}
/**
* Proxy method for {@link java.security.MessageDigest#digest(byte[], int, int)}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param buf
* @param offset
* @param len
* @return the result of the {@link java.security.MessageDigest#digest(byte[], int, int)} method
* @throws java.security.DigestException
*/
public int digest(byte buf[], int offset, int len) throws java.security.DigestException {
return algorithm.digest(buf, offset, len);
}
/**
* Proxy method for {@link java.security.MessageDigest#getAlgorithm}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @return the result of the {@link java.security.MessageDigest#getAlgorithm} method
*/
public String getJCEAlgorithmString() {
return algorithm.getAlgorithm();
}
/**
* Proxy method for {@link java.security.MessageDigest#getProvider}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @return the result of the {@link java.security.MessageDigest#getProvider} method
*/
public java.security.Provider getJCEProvider() {
return algorithm.getProvider();
}
/**
* Proxy method for {@link java.security.MessageDigest#getDigestLength}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @return the result of the {@link java.security.MessageDigest#getDigestLength} method
*/
public int getDigestLength() {
return algorithm.getDigestLength();
}
/**
* Proxy method for {@link java.security.MessageDigest#reset}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
*/
public void reset() {
algorithm.reset();
}
/**
* Proxy method for {@link java.security.MessageDigest#update(byte[])}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param input
*/
public void update(byte[] input) {
algorithm.update(input);
}
/**
* Proxy method for {@link java.security.MessageDigest#update(byte)}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param input
*/
public void update(byte input) {
algorithm.update(input);
}
/**
* Proxy method for {@link java.security.MessageDigest#update(byte[], int, int)}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param buf
* @param offset
* @param len
*/
public void update(byte buf[], int offset, int len) {
algorithm.update(buf, offset, len);
}
/** {@inheritDoc} */
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
/** {@inheritDoc} */
public String getBaseLocalName() {
return Constants._TAG_DIGESTMETHOD;
}
}

View File

@@ -0,0 +1,482 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureDSA;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Allows selection of digital signature's algorithm, private keys, other
* security parameters, and algorithm's ID.
*
*/
public class SignatureAlgorithm extends Algorithm {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(SignatureAlgorithm.class);
/** All available algorithm classes are registered here */
private static Map<String, Class<? extends SignatureAlgorithmSpi>> algorithmHash =
new ConcurrentHashMap<String, Class<? extends SignatureAlgorithmSpi>>();
/** Field signatureAlgorithm */
private final SignatureAlgorithmSpi signatureAlgorithm;
private final String algorithmURI;
/**
* Constructor SignatureAlgorithm
*
* @param doc
* @param algorithmURI
* @throws XMLSecurityException
*/
public SignatureAlgorithm(Document doc, String algorithmURI) throws XMLSecurityException {
super(doc, algorithmURI);
this.algorithmURI = algorithmURI;
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(getElement());
}
/**
* Constructor SignatureAlgorithm
*
* @param doc
* @param algorithmURI
* @param hmacOutputLength
* @throws XMLSecurityException
*/
public SignatureAlgorithm(
Document doc, String algorithmURI, int hmacOutputLength
) throws XMLSecurityException {
super(doc, algorithmURI);
this.algorithmURI = algorithmURI;
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(getElement());
signatureAlgorithm.engineSetHMACOutputLength(hmacOutputLength);
((IntegrityHmac)signatureAlgorithm).engineAddContextToElement(getElement());
}
/**
* Constructor SignatureAlgorithm
*
* @param element
* @param baseURI
* @throws XMLSecurityException
*/
public SignatureAlgorithm(Element element, String baseURI) throws XMLSecurityException {
this(element, baseURI, true);
}
/**
* Constructor SignatureAlgorithm
*
* @param element
* @param baseURI
* @param secureValidation
* @throws XMLSecurityException
*/
public SignatureAlgorithm(
Element element, String baseURI, boolean secureValidation
) throws XMLSecurityException {
super(element, baseURI);
algorithmURI = this.getURI();
Attr attr = element.getAttributeNodeNS(null, "Id");
if (attr != null) {
element.setIdAttributeNode(attr, true);
}
if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI)
|| XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) {
Object exArgs[] = { algorithmURI };
throw new XMLSecurityException("signature.signatureAlgorithm", exArgs);
}
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(getElement());
}
/**
* Get a SignatureAlgorithmSpi object corresponding to the algorithmURI argument
*/
private static SignatureAlgorithmSpi getSignatureAlgorithmSpi(String algorithmURI)
throws XMLSignatureException {
try {
Class<? extends SignatureAlgorithmSpi> implementingClass =
algorithmHash.get(algorithmURI);
LOG.debug("Create URI \"{}\" class \"{}\"", algorithmURI, implementingClass);
if (implementingClass == null) {
Object exArgs[] = { algorithmURI };
throw new XMLSignatureException("algorithms.NoSuchAlgorithmNoEx", exArgs);
}
SignatureAlgorithmSpi tmp = implementingClass.newInstance();
return tmp;
} catch (IllegalAccessException | InstantiationException | NullPointerException ex) {
Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException(ex, "algorithms.NoSuchAlgorithm", exArgs);
}
}
/**
* Proxy method for {@link java.security.Signature#sign()}
* which is executed on the internal {@link java.security.Signature} object.
*
* @return the result of the {@link java.security.Signature#sign()} method
* @throws XMLSignatureException
*/
public byte[] sign() throws XMLSignatureException {
return signatureAlgorithm.engineSign();
}
/**
* Proxy method for {@link java.security.Signature#getAlgorithm}
* which is executed on the internal {@link java.security.Signature} object.
*
* @return the result of the {@link java.security.Signature#getAlgorithm} method
*/
public String getJCEAlgorithmString() {
return signatureAlgorithm.engineGetJCEAlgorithmString();
}
/**
* Method getJCEProviderName
*
* @return The Provider of this Signature Algorithm
*/
public String getJCEProviderName() {
return signatureAlgorithm.engineGetJCEProviderName();
}
/**
* Proxy method for {@link java.security.Signature#update(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param input
* @throws XMLSignatureException
*/
public void update(byte[] input) throws XMLSignatureException {
signatureAlgorithm.engineUpdate(input);
}
/**
* Proxy method for {@link java.security.Signature#update(byte)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param input
* @throws XMLSignatureException
*/
public void update(byte input) throws XMLSignatureException {
signatureAlgorithm.engineUpdate(input);
}
/**
* Proxy method for {@link java.security.Signature#update(byte[], int, int)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param buf
* @param offset
* @param len
* @throws XMLSignatureException
*/
public void update(byte buf[], int offset, int len) throws XMLSignatureException {
signatureAlgorithm.engineUpdate(buf, offset, len);
}
/**
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signingKey
* @throws XMLSignatureException
*/
public void initSign(Key signingKey) throws XMLSignatureException {
signatureAlgorithm.engineInitSign(signingKey);
}
/**
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey,
* java.security.SecureRandom)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signingKey
* @param secureRandom
* @throws XMLSignatureException
*/
public void initSign(Key signingKey, SecureRandom secureRandom) throws XMLSignatureException {
signatureAlgorithm.engineInitSign(signingKey, secureRandom);
}
/**
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signingKey
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
public void initSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
signatureAlgorithm.engineInitSign(signingKey, algorithmParameterSpec);
}
/**
* Proxy method for {@link java.security.Signature#setParameter(
* java.security.spec.AlgorithmParameterSpec)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param params
* @throws XMLSignatureException
*/
public void setParameter(AlgorithmParameterSpec params) throws XMLSignatureException {
signatureAlgorithm.engineSetParameter(params);
}
/**
* Proxy method for {@link java.security.Signature#initVerify(java.security.PublicKey)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param verificationKey
* @throws XMLSignatureException
*/
public void initVerify(Key verificationKey) throws XMLSignatureException {
signatureAlgorithm.engineInitVerify(verificationKey);
}
/**
* Proxy method for {@link java.security.Signature#verify(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signature
* @return true if if the signature is valid.
*
* @throws XMLSignatureException
*/
public boolean verify(byte[] signature) throws XMLSignatureException {
return signatureAlgorithm.engineVerify(signature);
}
/**
* Returns the URI representation of Transformation algorithm
*
* @return the URI representation of Transformation algorithm
*/
public final String getURI() {
return getLocalAttribute(Constants._ATT_ALGORITHM);
}
/**
* Registers implementing class of the SignatureAlgorithm with algorithmURI
*
* @param algorithmURI algorithmURI URI representation of {@code SignatureAlgorithm}.
* @param implementingClass {@code implementingClass} the implementing class of
* {@link SignatureAlgorithmSpi}
* @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
* @throws XMLSignatureException
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to register the signature algorithm
*/
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
XMLSignatureException {
JavaUtils.checkRegisterPermission();
LOG.debug("Try to register {} {}", algorithmURI, implementingClass);
// are we already registered?
Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs
);
}
try {
Class<? extends SignatureAlgorithmSpi> clazz =
(Class<? extends SignatureAlgorithmSpi>)
ClassLoaderUtils.loadClass(implementingClass, SignatureAlgorithm.class);
algorithmHash.put(algorithmURI, clazz);
} catch (NullPointerException ex) {
Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException(ex, "algorithms.NoSuchAlgorithm", exArgs);
}
}
/**
* Registers implementing class of the SignatureAlgorithm with algorithmURI
*
* @param algorithmURI algorithmURI URI representation of {@code SignatureAlgorithm}.
* @param implementingClass {@code implementingClass} the implementing class of
* {@link SignatureAlgorithmSpi}
* @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
* @throws XMLSignatureException
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to register the signature algorithm
*/
public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
XMLSignatureException {
JavaUtils.checkRegisterPermission();
LOG.debug("Try to register {} {}", algorithmURI, implementingClass);
// are we already registered?
Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs
);
}
algorithmHash.put(algorithmURI, implementingClass);
}
/**
* This method registers the default algorithms.
*/
public static void registerDefaultAlgorithms() {
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256, SignatureDSA.SHA256.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5,
SignatureBaseRSA.SignatureRSAMD5.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160,
SignatureBaseRSA.SignatureRSARIPEMD160.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224, SignatureBaseRSA.SignatureRSASHA224.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1_MGF1, SignatureBaseRSA.SignatureRSASHA1MGF1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224_MGF1, SignatureBaseRSA.SignatureRSASHA224MGF1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256_MGF1, SignatureBaseRSA.SignatureRSASHA256MGF1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384_MGF1, SignatureBaseRSA.SignatureRSASHA384MGF1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512_MGF1, SignatureBaseRSA.SignatureRSASHA512MGF1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA224, SignatureECDSA.SignatureECDSASHA224.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_RIPEMD160, SignatureECDSA.SignatureECDSARIPEMD160.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA224, IntegrityHmac.IntegrityHmacSHA224.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class
);
}
/**
* Method getBaseNamespace
*
* @return URI of this element
*/
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
/**
* Method getBaseLocalName
*
* @return Local name
*/
public String getBaseLocalName() {
return Constants._TAG_SIGNATUREMETHOD;
}
}

View File

@@ -0,0 +1,177 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import org.w3c.dom.Element;
public abstract class SignatureAlgorithmSpi {
/**
* Returns the URI representation of {@code Transformation algorithm}
*
* @return the URI representation of {@code Transformation algorithm}
*/
protected abstract String engineGetURI();
/**
* Proxy method for {@link java.security.Signature#getAlgorithm}
* which is executed on the internal {@link java.security.Signature} object.
*
* @return the result of the {@link java.security.Signature#getAlgorithm} method
*/
protected abstract String engineGetJCEAlgorithmString();
/**
* Method engineGetJCEProviderName
*
* @return the JCE ProviderName
*/
protected abstract String engineGetJCEProviderName();
/**
* Proxy method for {@link java.security.Signature#update(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param input
* @throws XMLSignatureException
*/
protected abstract void engineUpdate(byte[] input) throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#update(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param input
* @throws XMLSignatureException
*/
protected abstract void engineUpdate(byte input) throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#update(byte[], int, int)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param buf
* @param offset
* @param len
* @throws XMLSignatureException
*/
protected abstract void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signingKey
* @throws XMLSignatureException if this method is called on a MAC
*/
protected abstract void engineInitSign(Key signingKey) throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey,
* java.security.SecureRandom)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signingKey
* @param secureRandom
* @throws XMLSignatureException if this method is called on a MAC
*/
protected abstract void engineInitSign(Key signingKey, SecureRandom secureRandom)
throws XMLSignatureException;
/**
* Proxy method for {@link javax.crypto.Mac}
* which is executed on the internal {@link javax.crypto.Mac#init(Key)} object.
*
* @param signingKey
* @param algorithmParameterSpec
* @throws XMLSignatureException if this method is called on a Signature
*/
protected abstract void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#sign()}
* which is executed on the internal {@link java.security.Signature} object.
*
* @return the result of the {@link java.security.Signature#sign()} method
* @throws XMLSignatureException
*/
protected abstract byte[] engineSign() throws XMLSignatureException;
/**
* Method engineInitVerify
*
* @param verificationKey
* @throws XMLSignatureException
*/
protected abstract void engineInitVerify(Key verificationKey) throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#verify(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signature
* @return true if the signature is correct
* @throws XMLSignatureException
*/
protected abstract boolean engineVerify(byte[] signature) throws XMLSignatureException;
/**
* Proxy method for {@link java.security.Signature#setParameter(
* java.security.spec.AlgorithmParameterSpec)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param params
* @throws XMLSignatureException
*/
protected abstract void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException;
/**
* Method engineGetContextFromElement
*
* @param element
*/
protected void engineGetContextFromElement(Element element) {
}
/**
* Method engineSetHMACOutputLength
*
* @param HMACOutputLength
* @throws XMLSignatureException
*/
protected abstract void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException;
public void reset() {
}
}

View File

@@ -0,0 +1,918 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.io.IOException;
import java.math.BigInteger;
import java.security.interfaces.ECPublicKey;
import java.security.spec.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public final class ECDSAUtils {
private ECDSAUtils() {
// complete
}
/**
* Converts an ASN.1 ECDSA value to a XML Signature ECDSA Value.
* <p></p>
* The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r, s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param asn1Bytes
* @return the decode bytes
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
if (asn1Bytes.length < 8 || asn1Bytes[0] != 48) {
throw new IOException("Invalid ASN.1 format of ECDSA signature");
}
int offset;
if (asn1Bytes[1] > 0) {
offset = 2;
} else if (asn1Bytes[1] == (byte) 0x81) {
offset = 3;
} else {
throw new IOException("Invalid ASN.1 format of ECDSA signature");
}
byte rLength = asn1Bytes[offset + 1];
int i;
for (i = rLength; i > 0 && asn1Bytes[offset + 2 + rLength - i] == 0; i--); //NOPMD
byte sLength = asn1Bytes[offset + 2 + rLength + 1];
int j;
for (j = sLength; j > 0 && asn1Bytes[offset + 2 + rLength + 2 + sLength - j] == 0; j--); //NOPMD
int rawLen = Math.max(i, j);
if ((asn1Bytes[offset - 1] & 0xff) != asn1Bytes.length - offset
|| (asn1Bytes[offset - 1] & 0xff) != 2 + rLength + 2 + sLength
|| asn1Bytes[offset] != 2
|| asn1Bytes[offset + 2 + rLength] != 2) {
throw new IOException("Invalid ASN.1 format of ECDSA signature");
}
byte xmldsigBytes[] = new byte[2 * rawLen];
System.arraycopy(asn1Bytes, offset + 2 + rLength - i, xmldsigBytes, rawLen - i, i);
System.arraycopy(asn1Bytes, offset + 2 + rLength + 2 + sLength - j, xmldsigBytes,
2 * rawLen - j, j);
return xmldsigBytes;
}
/**
* Converts a XML Signature ECDSA Value to an ASN.1 DSA value.
* <p></p>
* The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r, s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param xmldsigBytes
* @return the encoded ASN.1 bytes
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
int rawLen = xmldsigBytes.length / 2;
int i;
for (i = rawLen; i > 0 && xmldsigBytes[rawLen - i] == 0; i--); //NOPMD
int j = i;
if (xmldsigBytes[rawLen - i] < 0) {
j += 1;
}
int k;
for (k = rawLen; k > 0 && xmldsigBytes[2 * rawLen - k] == 0; k--); //NOPMD
int l = k;
if (xmldsigBytes[2 * rawLen - k] < 0) {
l += 1;
}
int len = 2 + j + 2 + l;
if (len > 255) {
throw new IOException("Invalid XMLDSIG format of ECDSA signature");
}
int offset;
byte asn1Bytes[];
if (len < 128) {
asn1Bytes = new byte[2 + 2 + j + 2 + l];
offset = 1;
} else {
asn1Bytes = new byte[3 + 2 + j + 2 + l];
asn1Bytes[1] = (byte) 0x81;
offset = 2;
}
asn1Bytes[0] = 48;
asn1Bytes[offset++] = (byte) len;
asn1Bytes[offset++] = 2;
asn1Bytes[offset++] = (byte) j;
System.arraycopy(xmldsigBytes, rawLen - i, asn1Bytes, offset + j - i, i);
offset += j;
asn1Bytes[offset++] = 2;
asn1Bytes[offset++] = (byte) l;
System.arraycopy(xmldsigBytes, 2 * rawLen - k, asn1Bytes, offset + l - k, k);
return asn1Bytes;
}
private static final List<ECCurveDefinition> ecCurveDefinitions = new ArrayList<>();
static {
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp112r1",
"1.3.132.0.6",
"db7c2abf62e35e668076bead208b",
"db7c2abf62e35e668076bead2088",
"659ef8ba043916eede8911702b22",
"09487239995a5ee76b55f9c2f098",
"a89ce5af8724c0a23e0e0ff77500",
"db7c2abf62e35e7628dfac6561c5",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp112r2",
"1.3.132.0.7",
"db7c2abf62e35e668076bead208b",
"6127c24c05f38a0aaaf65c0ef02c",
"51def1815db5ed74fcc34c85d709",
"4ba30ab5e892b4e1649dd0928643",
"adcd46f5882e3747def36e956e97",
"36df0aafd8b8d7597ca10520d04b",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp128r1",
"1.3.132.0.28",
"fffffffdffffffffffffffffffffffff",
"fffffffdfffffffffffffffffffffffc",
"e87579c11079f43dd824993c2cee5ed3",
"161ff7528b899b2d0c28607ca52c5b86",
"cf5ac8395bafeb13c02da292dded7a83",
"fffffffe0000000075a30d1b9038a115",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp128r2",
"1.3.132.0.29",
"fffffffdffffffffffffffffffffffff",
"d6031998d1b3bbfebf59cc9bbff9aee1",
"5eeefca380d02919dc2c6558bb6d8a5d",
"7b6aa5d85e572983e6fb32a7cdebc140",
"27b6916a894d3aee7106fe805fc34b44",
"3fffffff7fffffffbe0024720613b5a3",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp160k1",
"1.3.132.0.9",
"fffffffffffffffffffffffffffffffeffffac73",
"0000000000000000000000000000000000000000",
"0000000000000000000000000000000000000007",
"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
"938cf935318fdced6bc28286531733c3f03c4fee",
"0100000000000000000001b8fa16dfab9aca16b6b3",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp160r1",
"1.3.132.0.8",
"ffffffffffffffffffffffffffffffff7fffffff",
"ffffffffffffffffffffffffffffffff7ffffffc",
"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
"4a96b5688ef573284664698968c38bb913cbfc82",
"23a628553168947d59dcc912042351377ac5fb32",
"0100000000000000000001f4c8f927aed3ca752257",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp160r2",
"1.3.132.0.30",
"fffffffffffffffffffffffffffffffeffffac73",
"fffffffffffffffffffffffffffffffeffffac70",
"b4e134d3fb59eb8bab57274904664d5af50388ba",
"52dcb034293a117e1f4ff11b30f7199d3144ce6d",
"feaffef2e331f296e071fa0df9982cfea7d43f2e",
"0100000000000000000000351ee786a818f3a1a16b",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp192k1",
"1.3.132.0.31",
"fffffffffffffffffffffffffffffffffffffffeffffee37",
"000000000000000000000000000000000000000000000000",
"000000000000000000000000000000000000000000000003",
"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d",
"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp192r1 [NIST P-192, X9.62 prime192v1]",
"1.2.840.10045.3.1.1",
"fffffffffffffffffffffffffffffffeffffffffffffffff",
"fffffffffffffffffffffffffffffffefffffffffffffffc",
"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
"07192b95ffc8da78631011ed6b24cdd573f977a11e794811",
"ffffffffffffffffffffffff99def836146bc9b1b4d22831",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp224k1",
"1.3.132.0.32",
"fffffffffffffffffffffffffffffffffffffffffffffffeffffe56d",
"00000000000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000000005",
"a1455b334df099df30fc28a169a467e9e47075a90f7e650eb6b7a45c",
"7e089fed7fba344282cafbd6f7e319f7c0b0bd59e2ca4bdb556d61a5",
"010000000000000000000000000001dce8d2ec6184caf0a971769fb1f7",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp224r1 [NIST P-224]",
"1.3.132.0.33",
"ffffffffffffffffffffffffffffffff000000000000000000000001",
"fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
"b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
"b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
"bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34",
"ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp256k1",
"1.3.132.0.10",
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000007",
"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp256r1 [NIST P-256, X9.62 prime256v1]",
"1.2.840.10045.3.1.7",
"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5",
"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp384r1 [NIST P-384]",
"1.3.132.0.34",
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff",
"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc",
"b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef",
"aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7",
"3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",
"ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"secp521r1 [NIST P-521]",
"1.3.132.0.35",
"01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc",
"0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00",
"00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66",
"011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",
"01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 prime192v2",
"1.2.840.10045.3.1.2",
"fffffffffffffffffffffffffffffffeffffffffffffffff",
"fffffffffffffffffffffffffffffffefffffffffffffffc",
"cc22d6dfb95c6b25e49c0d6364a4e5980c393aa21668d953",
"eea2bae7e1497842f2de7769cfe9c989c072ad696f48034a",
"6574d11d69b6ec7a672bb82a083df2f2b0847de970b2de15",
"fffffffffffffffffffffffe5fb1a724dc80418648d8dd31",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 prime192v3",
"1.2.840.10045.3.1.3",
"fffffffffffffffffffffffffffffffeffffffffffffffff",
"fffffffffffffffffffffffffffffffefffffffffffffffc",
"22123dc2395a05caa7423daeccc94760a7d462256bd56916",
"7d29778100c65a1da1783716588dce2b8b4aee8e228f1896",
"38a90f22637337334b49dcb66a6dc8f9978aca7648a943b0",
"ffffffffffffffffffffffff7a62d031c83f4294f640ec13",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 prime239v1",
"1.2.840.10045.3.1.4",
"7fffffffffffffffffffffff7fffffffffff8000000000007fffffffffff",
"7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc",
"6b016c3bdcf18941d0d654921475ca71a9db2fb27d1d37796185c2942c0a",
"0ffa963cdca8816ccc33b8642bedf905c3d358573d3f27fbbd3b3cb9aaaf",
"7debe8e4e90a5dae6e4054ca530ba04654b36818ce226b39fccb7b02f1ae",
"7fffffffffffffffffffffff7fffff9e5e9a9f5d9071fbd1522688909d0b",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 prime239v2",
"1.2.840.10045.3.1.5",
"7fffffffffffffffffffffff7fffffffffff8000000000007fffffffffff",
"7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc",
"617fab6832576cbbfed50d99f0249c3fee58b94ba0038c7ae84c8c832f2c",
"38af09d98727705120c921bb5e9e26296a3cdcf2f35757a0eafd87b830e7",
"5b0125e4dbea0ec7206da0fc01d9b081329fb555de6ef460237dff8be4ba",
"7fffffffffffffffffffffff800000cfa7e8594377d414c03821bc582063",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 prime239v3",
"1.2.840.10045.3.1.6",
"7fffffffffffffffffffffff7fffffffffff8000000000007fffffffffff",
"7fffffffffffffffffffffff7fffffffffff8000000000007ffffffffffc",
"255705fa2a306654b1f4cb03d6a750a30c250102d4988717d9ba15ab6d3e",
"6768ae8e18bb92cfcf005c949aa2c6d94853d0e660bbf854b1c9505fe95a",
"1607e6898f390c06bc1d552bad226f3b6fcfe48b6e818499af18e3ed6cf3",
"7fffffffffffffffffffffff7fffff975deb41b3a6057c3c432146526551",
1)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect113r1",
"1.3.132.0.4",
"020000000000000000000000000201",
"003088250ca6e7c7fe649ce85820f7",
"00e8bee4d3e2260744188be0e9c723",
"009d73616f35f4ab1407d73562c10f",
"00a52830277958ee84d1315ed31886",
"0100000000000000d9ccec8a39e56f",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect113r2",
"1.3.132.0.5",
"020000000000000000000000000201",
"00689918dbec7e5a0dd6dfc0aa55c7",
"0095e9a9ec9b297bd4bf36e059184f",
"01a57a6a7b26ca5ef52fcdb8164797",
"00b3adc94ed1fe674c06e695baba1d",
"010000000000000108789b2496af93",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect131r1",
"1.3.132.0.22",
"080000000000000000000000000000010d",
"07a11b09a76b562144418ff3ff8c2570b8",
"0217c05610884b63b9c6c7291678f9d341",
"0081baf91fdf9833c40f9c181343638399",
"078c6e7ea38c001f73c8134b1b4ef9e150",
"0400000000000000023123953a9464b54d",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect131r2",
"1.3.132.0.23",
"080000000000000000000000000000010d",
"03e5a88919d7cafcbf415f07c2176573b2",
"04b8266a46c55657ac734ce38f018f2192",
"0356dcd8f2f95031ad652d23951bb366a8",
"0648f06d867940a5366d9e265de9eb240f",
"0400000000000000016954a233049ba98f",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect163k1 [NIST K-163]",
"1.3.132.0.1",
"0800000000000000000000000000000000000000c9",
"000000000000000000000000000000000000000001",
"000000000000000000000000000000000000000001",
"02fe13c0537bbc11acaa07d793de4e6d5e5c94eee8",
"0289070fb05d38ff58321f2e800536d538ccdaa3d9",
"04000000000000000000020108a2e0cc0d99f8a5ef",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect163r1",
"1.3.132.0.2",
"0800000000000000000000000000000000000000c9",
"07b6882caaefa84f9554ff8428bd88e246d2782ae2",
"0713612dcddcb40aab946bda29ca91f73af958afd9",
"0369979697ab43897789566789567f787a7876a654",
"00435edb42efafb2989d51fefce3c80988f41ff883",
"03ffffffffffffffffffff48aab689c29ca710279b",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect163r2 [NIST B-163]",
"1.3.132.0.15",
"0800000000000000000000000000000000000000c9",
"000000000000000000000000000000000000000001",
"020a601907b8c953ca1481eb10512f78744a3205fd",
"03f0eba16286a2d57ea0991168d4994637e8343e36",
"00d51fbc6c71a0094fa2cdd545b11c5c0c797324f1",
"040000000000000000000292fe77e70c12a4234c33",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect193r1",
"1.3.132.0.24",
"02000000000000000000000000000000000000000000008001",
"0017858feb7a98975169e171f77b4087de098ac8a911df7b01",
"00fdfb49bfe6c3a89facadaa7a1e5bbc7cc1c2e5d831478814",
"01f481bc5f0ff84a74ad6cdf6fdef4bf6179625372d8c0c5e1",
"0025e399f2903712ccf3ea9e3a1ad17fb0b3201b6af7ce1b05",
"01000000000000000000000000c7f34a778f443acc920eba49",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect193r2",
"1.3.132.0.25",
"02000000000000000000000000000000000000000000008001",
"0163f35a5137c2ce3ea6ed8667190b0bc43ecd69977702709b",
"00c9bb9e8927d4d64c377e2ab2856a5b16e3efb7f61d4316ae",
"00d9b67d192e0367c803f39e1a7e82ca14a651350aae617e8f",
"01ce94335607c304ac29e7defbd9ca01f596f927224cdecf6c",
"010000000000000000000000015aab561b005413ccd4ee99d5",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect233k1 [NIST K-233]",
"1.3.132.0.26",
"020000000000000000000000000000000000000004000000000000000001",
"000000000000000000000000000000000000000000000000000000000000",
"000000000000000000000000000000000000000000000000000000000001",
"017232ba853a7e731af129f22ff4149563a419c26bf50a4c9d6eefad6126",
"01db537dece819b7f70f555a67c427a8cd9bf18aeb9b56e0c11056fae6a3",
"008000000000000000000000000000069d5bb915bcd46efb1ad5f173abdf",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect233r1 [NIST B-233]",
"1.3.132.0.27",
"020000000000000000000000000000000000000004000000000000000001",
"000000000000000000000000000000000000000000000000000000000001",
"0066647ede6c332c7f8c0923bb58213b333b20e9ce4281fe115f7d8f90ad",
"00fac9dfcbac8313bb2139f1bb755fef65bc391f8b36f8f8eb7371fd558b",
"01006a08a41903350678e58528bebf8a0beff867a7ca36716f7e01f81052",
"01000000000000000000000000000013e974e72f8a6922031d2603cfe0d7",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect239k1",
"1.3.132.0.3",
"800000000000000000004000000000000000000000000000000000000001",
"000000000000000000000000000000000000000000000000000000000000",
"000000000000000000000000000000000000000000000000000000000001",
"29a0b6a887a983e9730988a68727a8b2d126c44cc2cc7b2a6555193035dc",
"76310804f12e549bdb011c103089e73510acb275fc312a5dc6b76553f0ca",
"2000000000000000000000000000005a79fec67cb6e91f1c1da800e478a5",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect283k1 [NIST K-283]",
"1.3.132.0.16",
"0800000000000000000000000000000000000000000000000000000000000000000010a1",
"000000000000000000000000000000000000000000000000000000000000000000000000",
"000000000000000000000000000000000000000000000000000000000000000000000001",
"0503213f78ca44883f1a3b8162f188e553cd265f23c1567a16876913b0c2ac2458492836",
"01ccda380f1c9e318d90f95d07e5426fe87e45c0e8184698e45962364e34116177dd2259",
"01ffffffffffffffffffffffffffffffffffe9ae2ed07577265dff7f94451e061e163c61",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect283r1 [NIST B-283]",
"1.3.132.0.17",
"0800000000000000000000000000000000000000000000000000000000000000000010a1",
"000000000000000000000000000000000000000000000000000000000000000000000001",
"027b680ac8b8596da5a4af8a19a0303fca97fd7645309fa2a581485af6263e313b79a2f5",
"05f939258db7dd90e1934f8c70b0dfec2eed25b8557eac9c80e2e198f8cdbecd86b12053",
"03676854fe24141cb98fe6d4b20d02b4516ff702350eddb0826779c813f0df45be8112f4",
"03ffffffffffffffffffffffffffffffffffef90399660fc938a90165b042a7cefadb307",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect409k1 [NIST K-409]",
"1.3.132.0.36",
"02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001",
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"0060f05f658f49c1ad3ab1890f7184210efd0987e307c84c27accfb8f9f67cc2c460189eb5aaaa62ee222eb1b35540cfe9023746",
"01e369050b7c4e42acba1dacbf04299c3460782f918ea427e6325165e9ea10e3da5f6c42e9c55215aa9ca27a5863ec48d8e0286b",
"007ffffffffffffffffffffffffffffffffffffffffffffffffffe5f83b2d4ea20400ec4557d5ed3e3e7ca5b4b5c83b8e01e5fcf",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect409r1 [NIST B-409]",
"1.3.132.0.37",
"02000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000001",
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"0021a5c2c8ee9feb5c4b9a753b7b476b7fd6422ef1f3dd674761fa99d6ac27c8a9a197b272822f6cd57a55aa4f50ae317b13545f",
"015d4860d088ddb3496b0c6064756260441cde4af1771d4db01ffe5b34e59703dc255a868a1180515603aeab60794e54bb7996a7",
"0061b1cfab6be5f32bbfa78324ed106a7636b9c5a7bd198d0158aa4f5488d08f38514f1fdf4b4f40d2181b3681c364ba0273c706",
"010000000000000000000000000000000000000000000000000001e2aad6a612f33307be5fa47c3c9e052f838164cd37d9a21173",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect571k1 [NIST K-571]",
"1.3.132.0.38",
"080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425",
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"026eb7a859923fbc82189631f8103fe4ac9ca2970012d5d46024804801841ca44370958493b205e647da304db4ceb08cbbd1ba39494776fb988b47174dca88c7e2945283a01c8972",
"0349dc807f4fbf374f4aeade3bca95314dd58cec9f307a54ffc61efc006d8a2c9d4979c0ac44aea74fbebbb9f772aedcb620b01a7ba7af1b320430c8591984f601cd4c143ef1c7a3",
"020000000000000000000000000000000000000000000000000000000000000000000000131850e1f19a63e4b391a8db917f4138b630d84be5d639381e91deb45cfe778f637c1001",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"sect571r1 [NIST B-571]",
"1.3.132.0.39",
"080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000425",
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"02f40e7e2221f295de297117b7f3d62f5c6a97ffcb8ceff1cd6ba8ce4a9a18ad84ffabbd8efa59332be7ad6756a66e294afd185a78ff12aa520e4de739baca0c7ffeff7f2955727a",
"0303001d34b856296c16c0d40d3cd7750a93d1d2955fa80aa5f40fc8db7b2abdbde53950f4c0d293cdd711a35b67fb1499ae60038614f1394abfa3b4c850d927e1e7769c8eec2d19",
"037bf27342da639b6dccfffeb73d69d78c6c27a6009cbbca1980f8533921e8a684423e43bab08a576291af8f461bb2a8b3531d2f0485c19b16e2f1516e23dd3c1a4827af1b8ac15b",
"03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe661ce18ff55987308059b186823851ec7dd9ca1161de93d5174d66e8382e9bb2fe84e47",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb191v1",
"1.2.840.10045.3.0.5",
"800000000000000000000000000000000000000000000201",
"2866537b676752636a68f56554e12640276b649ef7526267",
"2e45ef571f00786f67b0081b9495a3d95462f5de0aa185ec",
"36b3daf8a23206f9c4f299d7b21a9c369137f2c84ae1aa0d",
"765be73433b3f95e332932e70ea245ca2418ea0ef98018fb",
"40000000000000000000000004a20e90c39067c893bbb9a5",
2)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb191v2",
"1.2.840.10045.3.0.6",
"800000000000000000000000000000000000000000000201",
"401028774d7777c7b7666d1366ea432071274f89ff01e718",
"0620048d28bcbd03b6249c99182b7c8cd19700c362c46a01",
"3809b2b7cc1b28cc5a87926aad83fd28789e81e2c9e3bf10",
"17434386626d14f3dbf01760d9213a3e1cf37aec437d668a",
"20000000000000000000000050508cb89f652824e06b8173",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb191v3",
"1.2.840.10045.3.0.7",
"800000000000000000000000000000000000000000000201",
"6c01074756099122221056911c77d77e77a777e7e7e77fcb",
"71fe1af926cf847989efef8db459f66394d90f32ad3f15e8",
"375d4ce24fde434489de8746e71786015009e66e38a926dd",
"545a39176196575d985999366e6ad34ce0a77cd7127b06be",
"155555555555555555555555610c0b196812bfb6288a3ea3",
6)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb239v1",
"1.2.840.10045.3.0.11",
"800000000000000000000000000000000000000000000000001000000001",
"32010857077c5431123a46b808906756f543423e8d27877578125778ac76",
"790408f2eedaf392b012edefb3392f30f4327c0ca3f31fc383c422aa8c16",
"57927098fa932e7c0a96d3fd5b706ef7e5f5c156e16b7e7c86038552e91d",
"61d8ee5077c33fecf6f1a16b268de469c3c7744ea9a971649fc7a9616305",
"2000000000000000000000000000000f4d42ffe1492a4993f1cad666e447",
4)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb239v2",
"1.2.840.10045.3.0.12",
"800000000000000000000000000000000000000000000000001000000001",
"4230017757a767fae42398569b746325d45313af0766266479b75654e65f",
"5037ea654196cff0cd82b2c14a2fcf2e3ff8775285b545722f03eacdb74b",
"28f9d04e900069c8dc47a08534fe76d2b900b7d7ef31f5709f200c4ca205",
"5667334c45aff3b5a03bad9dd75e2c71a99362567d5453f7fa6e227ec833",
"1555555555555555555555555555553c6f2885259c31e3fcdf154624522d",
6)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb239v3",
"1.2.840.10045.3.0.13",
"800000000000000000000000000000000000000000000000001000000001",
"01238774666a67766d6676f778e676b66999176666e687666d8766c66a9f",
"6a941977ba9f6a435199acfc51067ed587f519c5ecb541b8e44111de1d40",
"70f6e9d04d289c4e89913ce3530bfde903977d42b146d539bf1bde4e9c92",
"2e5a0eaf6e5e1305b9004dce5c0ed7fe59a35608f33837c816d80b79f461",
"0cccccccccccccccccccccccccccccac4912d2d9df903ef9888b8a0e4cff",
0xA)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb359v1",
"1.2.840.10045.3.0.18",
"800000000000000000000000000000000000000000000000000000000000000000000000100000000000000001",
"5667676a654b20754f356ea92017d946567c46675556f19556a04616b567d223a5e05656fb549016a96656a557",
"2472e2d0197c49363f1fe7f5b6db075d52b6947d135d8ca445805d39bc345626089687742b6329e70680231988",
"3c258ef3047767e7ede0f1fdaa79daee3841366a132e163aced4ed2401df9c6bdcde98e8e707c07a2239b1b097",
"53d7e08529547048121e9c95f3791dd804963948f34fae7bf44ea82365dc7868fe57e4ae2de211305a407104bd",
"01af286bca1af286bca1af286bca1af286bca1af286bc9fb8f6b85c556892c20a7eb964fe7719e74f490758d3b",
0x4C)
);
ecCurveDefinitions.add(
new ECCurveDefinition(
"X9.62 c2tnb431r1",
"1.2.840.10045.3.0.20",
"800000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000001",
"1a827ef00dd6fc0e234caf046c6a5d8a85395b236cc4ad2cf32a0cadbdc9ddf620b0eb9906d0957f6c6feacd615468df104de296cd8f",
"10d9b4a3d9047d8b154359abfb1b7f5485b04ceb868237ddc9deda982a679a5a919b626d4e50a8dd731b107a9962381fb5d807bf2618",
"120fc05d3c67a99de161d2f4092622feca701be4f50f4758714e8a87bbf2a658ef8c21e7c5efe965361f6c2999c0c247b0dbd70ce6b7",
"20d0af8903a96f8d5fa2c255745d3c451b302c9346d9b7e485e7bce41f6b591f3e8f6addcbb0bc4c2f947a7de1a89b625d6a598b3760",
"0340340340340340340340340340340340340340340340340340340323c313fab50589703b5ec68d3587fec60d161cc149c1ad4a91",
0x2760)
);
}
public static String getOIDFromPublicKey(ECPublicKey ecPublicKey) {
ECParameterSpec ecParameterSpec = ecPublicKey.getParams();
BigInteger order = ecParameterSpec.getOrder();
BigInteger affineX = ecParameterSpec.getGenerator().getAffineX();
BigInteger affineY = ecParameterSpec.getGenerator().getAffineY();
BigInteger a = ecParameterSpec.getCurve().getA();
BigInteger b = ecParameterSpec.getCurve().getB();
int h = ecParameterSpec.getCofactor();
ECField ecField = ecParameterSpec.getCurve().getField();
BigInteger field;
if (ecField instanceof ECFieldFp) {
ECFieldFp ecFieldFp = (ECFieldFp) ecField;
field = ecFieldFp.getP();
} else {
ECFieldF2m ecFieldF2m = (ECFieldF2m) ecField;
field = ecFieldF2m.getReductionPolynomial();
}
Iterator<ECCurveDefinition> ecCurveDefinitionIterator = ecCurveDefinitions.iterator();
while (ecCurveDefinitionIterator.hasNext()) {
ECCurveDefinition ecCurveDefinition = ecCurveDefinitionIterator.next();
String oid = ecCurveDefinition.equals(field, a, b, affineX, affineY, order, h);
if (oid != null) {
return oid;
}
}
return null;
}
public static ECCurveDefinition getECCurveDefinition(String oid) {
Iterator<ECCurveDefinition> ecCurveDefinitionIterator = ecCurveDefinitions.iterator();
while (ecCurveDefinitionIterator.hasNext()) {
ECCurveDefinition ecCurveDefinition = ecCurveDefinitionIterator.next();
if (ecCurveDefinition.getOid().equals(oid)) {
return ecCurveDefinition;
}
}
return null;
}
public static class ECCurveDefinition {
private final String name;
private final String oid;
private final String field;
private final String a;
private final String b;
private final String x;
private final String y;
private final String n;
private final int h;
public ECCurveDefinition(String name, String oid, String field, String a, String b, String x, String y, String n, int h) {
this.name = name;
this.oid = oid;
this.field = field;
this.a = a;
this.b = b;
this.x = x;
this.y = y;
this.n = n;
this.h = h;
}
/**
* returns the ec oid if parameter are equal to this definition
*/
public String equals(BigInteger field, BigInteger a, BigInteger b, BigInteger x, BigInteger y, BigInteger n, int h) {
if (this.field.equals(field.toString(16))
&& this.a.equals(a.toString(16))
&& this.b.equals(b.toString(16))
&& this.x.equals(x.toString(16))
&& this.y.equals(y.toString(16))
&& this.n.equals(n.toString(16))
&& this.h == h) {
return this.oid;
}
return null;
}
public String getName() {
return name;
}
public String getOid() {
return oid;
}
public String getField() {
return field;
}
public String getA() {
return a;
}
public String getB() {
return b;
}
public String getX() {
return x;
}
public String getY() {
return y;
}
public String getN() {
return n;
}
public int getH() {
return h;
}
}
public static byte[] encodePoint(ECPoint ecPoint, EllipticCurve ellipticCurve) {
int size = (ellipticCurve.getField().getFieldSize() + 7) / 8;
byte affineXBytes[] = stripLeadingZeros(ecPoint.getAffineX().toByteArray());
byte affineYBytes[] = stripLeadingZeros(ecPoint.getAffineY().toByteArray());
byte encodedBytes[] = new byte[size * 2 + 1];
encodedBytes[0] = 0x04; //uncompressed
System.arraycopy(affineXBytes, 0, encodedBytes, size - affineXBytes.length + 1, affineXBytes.length);
System.arraycopy(affineYBytes, 0, encodedBytes, encodedBytes.length - affineYBytes.length, affineYBytes.length);
return encodedBytes;
}
public static ECPoint decodePoint(byte[] encodedBytes, EllipticCurve elliptiCcurve) {
if (encodedBytes[0] != 0x04) {
throw new IllegalArgumentException("Only uncompressed format is supported");
}
int size = (elliptiCcurve.getField().getFieldSize() + 7) / 8;
byte affineXBytes[] = new byte[size];
byte affineYBytes[] = new byte[size];
System.arraycopy(encodedBytes, 1, affineXBytes, 0, size);
System.arraycopy(encodedBytes, size + 1, affineYBytes, 0, size);
return new ECPoint(new BigInteger(1, affineXBytes), new BigInteger(1, affineYBytes));
}
public static byte[] stripLeadingZeros(byte[] bytes) {
int i;
for (i = 0; i < bytes.length - 1; i++) {
if (bytes[i] != 0) {
break;
}
}
if (i == 0) {
return bytes;
} else {
byte stripped[] = new byte[bytes.length - i];
System.arraycopy(bytes, i, stripped, 0, stripped.length);
return stripped;
}
}
}

View File

@@ -0,0 +1,558 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(IntegrityHmac.class);
/** Field macAlgorithm */
private Mac macAlgorithm;
/** Field HMACOutputLength */
private int HMACOutputLength;
private boolean HMACOutputLengthSet = false;
/**
* Method engineGetURI
*
*{@inheritDoc}
*/
public abstract String engineGetURI();
/**
* Returns the output length of the hash/digest.
*/
abstract int getDigestLength();
/**
* Method IntegrityHmac
*
* @throws XMLSignatureException
*/
public IntegrityHmac() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
LOG.debug("Created IntegrityHmacSHA1 using {}", algorithmID);
try {
this.macAlgorithm = Mac.getInstance(algorithmID);
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
/**
* Proxy method for {@link java.security.Signature#setParameter(
* java.security.spec.AlgorithmParameterSpec)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param params
* @throws XMLSignatureException
*/
protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSignatureException {
throw new XMLSignatureException("empty", new Object[]{"Incorrect method call"});
}
public void reset() {
HMACOutputLength = 0;
HMACOutputLengthSet = false;
this.macAlgorithm.reset();
}
/**
* Proxy method for {@link java.security.Signature#verify(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param signature
* @return true if the signature is correct
* @throws XMLSignatureException
*/
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
LOG.debug("HMACOutputLength must not be less than {}", getDigestLength());
Object[] exArgs = { String.valueOf(getDigestLength()) };
throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
} else {
byte[] completeResult = this.macAlgorithm.doFinal();
return MessageDigestAlgorithm.isEqual(completeResult, signature);
}
} catch (IllegalStateException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Proxy method for {@link java.security.Signature#initVerify(java.security.PublicKey)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param secretKey
* @throws XMLSignatureException
*/
protected void engineInitVerify(Key secretKey) throws XMLSignatureException {
if (!(secretKey instanceof SecretKey)) {
String supplied = null;
if (secretKey != null) {
supplied = secretKey.getClass().getName();
}
String needed = SecretKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this.macAlgorithm.init(secretKey);
} catch (InvalidKeyException ex) {
// reinstantiate Mac object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Mac mac = this.macAlgorithm;
try {
this.macAlgorithm = Mac.getInstance(macAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous Mac
LOG.debug("Exception when reinstantiating Mac: {}", e);
this.macAlgorithm = mac;
}
throw new XMLSignatureException(ex);
}
}
/**
* Proxy method for {@link java.security.Signature#sign()}
* which is executed on the internal {@link java.security.Signature} object.
*
* @return the result of the {@link java.security.Signature#sign()} method
* @throws XMLSignatureException
*/
protected byte[] engineSign() throws XMLSignatureException {
try {
if (this.HMACOutputLengthSet && this.HMACOutputLength < getDigestLength()) {
LOG.debug("HMACOutputLength must not be less than {}", getDigestLength());
Object[] exArgs = { String.valueOf(getDigestLength()) };
throw new XMLSignatureException("algorithms.HMACOutputLengthMin", exArgs);
} else {
return this.macAlgorithm.doFinal();
}
} catch (IllegalStateException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Method engineInitSign
*
* @param secretKey
* @throws XMLSignatureException
*/
protected void engineInitSign(Key secretKey) throws XMLSignatureException {
engineInitSign(secretKey, (AlgorithmParameterSpec)null);
}
/**
* Method engineInitSign
*
* @param secretKey
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
protected void engineInitSign(
Key secretKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
if (!(secretKey instanceof SecretKey)) {
String supplied = null;
if (secretKey != null) {
supplied = secretKey.getClass().getName();
}
String needed = SecretKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
if (algorithmParameterSpec == null) {
this.macAlgorithm.init(secretKey);
} else {
this.macAlgorithm.init(secretKey, algorithmParameterSpec);
}
} catch (InvalidKeyException ex) {
throw new XMLSignatureException(ex);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Method engineInitSign
*
* @param secretKey
* @param secureRandom
* @throws XMLSignatureException
*/
protected void engineInitSign(Key secretKey, SecureRandom secureRandom)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.CannotUseSecureRandomOnMAC");
}
/**
* Proxy method for {@link java.security.Signature#update(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param input
* @throws XMLSignatureException
*/
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.macAlgorithm.update(input);
} catch (IllegalStateException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Proxy method for {@link java.security.Signature#update(byte)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param input
* @throws XMLSignatureException
*/
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.macAlgorithm.update(input);
} catch (IllegalStateException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Proxy method for {@link java.security.Signature#update(byte[], int, int)}
* which is executed on the internal {@link java.security.Signature} object.
*
* @param buf
* @param offset
* @param len
* @throws XMLSignatureException
*/
protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.macAlgorithm.update(buf, offset, len);
} catch (IllegalStateException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Method engineGetJCEAlgorithmString
* {@inheritDoc}
*
*/
protected String engineGetJCEAlgorithmString() {
return this.macAlgorithm.getAlgorithm();
}
/**
* Method engineGetJCEAlgorithmString
*
* {@inheritDoc}
*/
protected String engineGetJCEProviderName() {
return this.macAlgorithm.getProvider().getName();
}
/**
* Method engineSetHMACOutputLength
*
* @param HMACOutputLength
*/
protected void engineSetHMACOutputLength(int HMACOutputLength) {
this.HMACOutputLength = HMACOutputLength;
this.HMACOutputLengthSet = true;
}
/**
* Method engineGetContextFromElement
*
* @param element
*/
protected void engineGetContextFromElement(Element element) {
super.engineGetContextFromElement(element);
if (element == null) {
throw new IllegalArgumentException("element null");
}
Node n = XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_HMACOUTPUTLENGTH, 0);
if (n != null) {
String hmacLength = XMLUtils.getFullTextChildrenFromNode(n);
if (hmacLength != null && !"".equals(hmacLength)) {
this.HMACOutputLength = Integer.parseInt(hmacLength);
this.HMACOutputLengthSet = true;
}
}
}
/**
* Method engineAddContextToElement
*
* @param element
*/
public void engineAddContextToElement(Element element) {
if (element == null) {
throw new IllegalArgumentException("null element");
}
if (this.HMACOutputLengthSet) {
Document doc = element.getOwnerDocument();
Element HMElem =
XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_HMACOUTPUTLENGTH);
Text HMText =
doc.createTextNode("" + this.HMACOutputLength);
HMElem.appendChild(HMText);
XMLUtils.addReturnToElement(element);
element.appendChild(HMElem);
XMLUtils.addReturnToElement(element);
}
}
/**
* Class IntegrityHmacSHA1
*/
public static class IntegrityHmacSHA1 extends IntegrityHmac {
/**
* Constructor IntegrityHmacSHA1
*
* @throws XMLSignatureException
*/
public IntegrityHmacSHA1() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
* {@inheritDoc}
*
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_SHA1;
}
int getDigestLength() {
return 160;
}
}
/**
* Class IntegrityHmacSHA224
*/
public static class IntegrityHmacSHA224 extends IntegrityHmac {
/**
* Constructor IntegrityHmacSHA224
*
* @throws XMLSignatureException
*/
public IntegrityHmacSHA224() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
*
* {@inheritDoc}
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_SHA224;
}
int getDigestLength() {
return 224;
}
}
/**
* Class IntegrityHmacSHA256
*/
public static class IntegrityHmacSHA256 extends IntegrityHmac {
/**
* Constructor IntegrityHmacSHA256
*
* @throws XMLSignatureException
*/
public IntegrityHmacSHA256() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
*
* {@inheritDoc}
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_SHA256;
}
int getDigestLength() {
return 256;
}
}
/**
* Class IntegrityHmacSHA384
*/
public static class IntegrityHmacSHA384 extends IntegrityHmac {
/**
* Constructor IntegrityHmacSHA384
*
* @throws XMLSignatureException
*/
public IntegrityHmacSHA384() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
* {@inheritDoc}
*
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_SHA384;
}
int getDigestLength() {
return 384;
}
}
/**
* Class IntegrityHmacSHA512
*/
public static class IntegrityHmacSHA512 extends IntegrityHmac {
/**
* Constructor IntegrityHmacSHA512
*
* @throws XMLSignatureException
*/
public IntegrityHmacSHA512() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
* {@inheritDoc}
*
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_SHA512;
}
int getDigestLength() {
return 512;
}
}
/**
* Class IntegrityHmacRIPEMD160
*/
public static class IntegrityHmacRIPEMD160 extends IntegrityHmac {
/**
* Constructor IntegrityHmacRIPEMD160
*
* @throws XMLSignatureException
*/
public IntegrityHmacRIPEMD160() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
*
* {@inheritDoc}
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160;
}
int getDigestLength() {
return 160;
}
}
/**
* Class IntegrityHmacMD5
*/
public static class IntegrityHmacMD5 extends IntegrityHmac {
/**
* Constructor IntegrityHmacMD5
*
* @throws XMLSignatureException
*/
public IntegrityHmacMD5() throws XMLSignatureException {
super();
}
/**
* Method engineGetURI
*
* {@inheritDoc}
*/
public String engineGetURI() {
return XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5;
}
int getDigestLength() {
return 128;
}
}
}

View File

@@ -0,0 +1,457 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(SignatureBaseRSA.class);
/** {@inheritDoc} */
public abstract String engineGetURI();
/** Field algorithm */
private Signature signatureAlgorithm;
/**
* Constructor SignatureRSA
*
* @throws XMLSignatureException
*/
public SignatureBaseRSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
LOG.debug("Created SignatureRSA using {}", algorithmID);
String provider = JCEMapper.getProviderId();
try {
if (provider == null) {
this.signatureAlgorithm = Signature.getInstance(algorithmID);
} else {
this.signatureAlgorithm = Signature.getInstance(algorithmID, provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
/** {@inheritDoc} */
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
this.signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
return this.signatureAlgorithm.verify(signature);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = null;
if (publicKey != null) {
supplied = publicKey.getClass().getName();
}
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this.signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this.signatureAlgorithm;
try {
this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous
// Signature
LOG.debug("Exception when reinstantiating Signature: {}", e);
this.signatureAlgorithm = sig;
}
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected byte[] engineSign() throws XMLSignatureException {
try {
return this.signatureAlgorithm.sign();
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = null;
if (privateKey != null) {
supplied = privateKey.getClass().getName();
}
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
if (secureRandom == null) {
this.signatureAlgorithm.initSign((PrivateKey) privateKey);
} else {
this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom);
}
} catch (InvalidKeyException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
/** {@inheritDoc} */
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
/** {@inheritDoc} */
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
/** {@inheritDoc} */
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** {@inheritDoc} */
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
throw new XMLSignatureException("algorithms.CannotUseAlgorithmParameterSpecOnRSA");
}
/**
* Class SignatureRSASHA1
*/
public static class SignatureRSASHA1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1;
}
}
/**
* Class SignatureRSASHA224
*/
public static class SignatureRSASHA224 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA224
*
* @throws XMLSignatureException
*/
public SignatureRSASHA224() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224;
}
}
/**
* Class SignatureRSASHA256
*/
public static class SignatureRSASHA256 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA256
*
* @throws XMLSignatureException
*/
public SignatureRSASHA256() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256;
}
}
/**
* Class SignatureRSASHA384
*/
public static class SignatureRSASHA384 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA384
*
* @throws XMLSignatureException
*/
public SignatureRSASHA384() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384;
}
}
/**
* Class SignatureRSASHA512
*/
public static class SignatureRSASHA512 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA512
*
* @throws XMLSignatureException
*/
public SignatureRSASHA512() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512;
}
}
/**
* Class SignatureRSARIPEMD160
*/
public static class SignatureRSARIPEMD160 extends SignatureBaseRSA {
/**
* Constructor SignatureRSARIPEMD160
*
* @throws XMLSignatureException
*/
public SignatureRSARIPEMD160() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160;
}
}
/**
* Class SignatureRSAMD5
*/
public static class SignatureRSAMD5 extends SignatureBaseRSA {
/**
* Constructor SignatureRSAMD5
*
* @throws XMLSignatureException
*/
public SignatureRSAMD5() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5;
}
}
/**
* Class SignatureRSASHA1MGF1
*/
public static class SignatureRSASHA1MGF1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA1MGF1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA1MGF1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1_MGF1;
}
}
/**
* Class SignatureRSASHA224MGF1
*/
public static class SignatureRSASHA224MGF1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA224MGF1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA224MGF1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224_MGF1;
}
}
/**
* Class SignatureRSASHA256MGF1
*/
public static class SignatureRSASHA256MGF1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA256MGF1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA256MGF1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256_MGF1;
}
}
/**
* Class SignatureRSASHA384MGF1
*/
public static class SignatureRSASHA384MGF1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA384MGF1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA384MGF1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384_MGF1;
}
}
/**
* Class SignatureRSASHA512MGF1
*/
public static class SignatureRSASHA512MGF1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA512MGF1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA512MGF1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512_MGF1;
}
}
}

View File

@@ -0,0 +1,294 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureException;
import java.security.interfaces.DSAKey;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
public class SignatureDSA extends SignatureAlgorithmSpi {
public static final String URI = Constants.SignatureSpecNS + "dsa-sha1";
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(SignatureDSA.class);
/** Field algorithm */
private Signature signatureAlgorithm;
/** size of Q */
private int size;
/**
* Method engineGetURI
*
* {@inheritDoc}
*/
protected String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_DSA;
}
/**
* Constructor SignatureDSA
*
* @throws XMLSignatureException
*/
public SignatureDSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(engineGetURI());
LOG.debug("Created SignatureDSA using {}", algorithmID);
String provider = JCEMapper.getProviderId();
try {
if (provider == null) {
this.signatureAlgorithm = Signature.getInstance(algorithmID);
} else {
this.signatureAlgorithm =
Signature.getInstance(algorithmID, provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (java.security.NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
/**
* {@inheritDoc}
*/
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
this.signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* {@inheritDoc}
*/
protected boolean engineVerify(byte[] signature)
throws XMLSignatureException {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Called DSA.verify() on " + XMLUtils.encodeToString(signature));
}
byte[] jcebytes = JavaUtils.convertDsaXMLDSIGtoASN1(signature,
size/8);
return this.signatureAlgorithm.verify(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
} catch (IOException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* {@inheritDoc}
*/
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = null;
if (publicKey != null) {
supplied = publicKey.getClass().getName();
}
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this.signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this.signatureAlgorithm;
try {
this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous
// Signature
LOG.debug("Exception when reinstantiating Signature: {}", e);
this.signatureAlgorithm = sig;
}
throw new XMLSignatureException(ex);
}
size = ((DSAKey)publicKey).getParams().getQ().bitLength();
}
/**
* {@inheritDoc}
*/
protected byte[] engineSign() throws XMLSignatureException {
try {
byte jcebytes[] = this.signatureAlgorithm.sign();
return JavaUtils.convertDsaASN1toXMLDSIG(jcebytes, size/8);
} catch (IOException ex) {
throw new XMLSignatureException(ex);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* {@inheritDoc}
*/
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = null;
if (privateKey != null) {
supplied = privateKey.getClass().getName();
}
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
if (secureRandom == null) {
this.signatureAlgorithm.initSign((PrivateKey) privateKey);
} else {
this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom);
}
} catch (InvalidKeyException ex) {
throw new XMLSignatureException(ex);
}
size = ((DSAKey)privateKey).getParams().getQ().bitLength();
}
/**
* {@inheritDoc}
*/
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
/**
* {@inheritDoc}
*/
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* {@inheritDoc}
*/
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* {@inheritDoc}
*/
protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/**
* Method engineGetJCEAlgorithmString
*
* {@inheritDoc}
*/
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
/**
* Method engineGetJCEProviderName
*
* {@inheritDoc}
*/
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
/**
* Method engineSetHMACOutputLength
*
* @param HMACOutputLength
* @throws XMLSignatureException
*/
protected void engineSetHMACOutputLength(int HMACOutputLength) throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/**
* Method engineInitSign
*
* @param signingKey
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
throw new XMLSignatureException("algorithms.CannotUseAlgorithmParameterSpecOnDSA");
}
public static class SHA256 extends SignatureDSA {
public SHA256() throws XMLSignatureException {
super();
}
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_DSA_SHA256;
}
}
}

View File

@@ -0,0 +1,394 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
/**
*
*/
public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
private static final com.sun.org.slf4j.internal.Logger LOG =
com.sun.org.slf4j.internal.LoggerFactory.getLogger(SignatureECDSA.class);
/** {@inheritDoc} */
public abstract String engineGetURI();
/** Field algorithm */
private Signature signatureAlgorithm;
/**
* Converts an ASN.1 ECDSA value to a XML Signature ECDSA Value.
*
* The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r, s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param asn1Bytes
* @return the decode bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
public static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
return ECDSAUtils.convertASN1toXMLDSIG(asn1Bytes);
}
/**
* Converts a XML Signature ECDSA Value to an ASN.1 DSA value.
*
* The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r, s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param xmldsigBytes
* @return the encoded ASN.1 bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
public static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
return ECDSAUtils.convertXMLDSIGtoASN1(xmldsigBytes);
}
/**
* Constructor SignatureRSA
*
* @throws XMLSignatureException
*/
public SignatureECDSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
LOG.debug("Created SignatureECDSA using {}", algorithmID);
String provider = JCEMapper.getProviderId();
try {
if (provider == null) {
this.signatureAlgorithm = Signature.getInstance(algorithmID);
} else {
this.signatureAlgorithm = Signature.getInstance(algorithmID, provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
/** {@inheritDoc} */
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
this.signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
try {
byte[] jcebytes = SignatureECDSA.convertXMLDSIGtoASN1(signature);
if (LOG.isDebugEnabled()) {
LOG.debug("Called ECDSA.verify() on " + XMLUtils.encodeToString(signature));
}
return this.signatureAlgorithm.verify(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
} catch (IOException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = null;
if (publicKey != null) {
supplied = publicKey.getClass().getName();
}
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this.signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this.signatureAlgorithm;
try {
this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous
// Signature
LOG.debug("Exception when reinstantiating Signature: {}", e);
this.signatureAlgorithm = sig;
}
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected byte[] engineSign() throws XMLSignatureException {
try {
byte jcebytes[] = this.signatureAlgorithm.sign();
return SignatureECDSA.convertASN1toXMLDSIG(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
} catch (IOException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = null;
if (privateKey != null) {
supplied = privateKey.getClass().getName();
}
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
if (secureRandom == null) {
this.signatureAlgorithm.initSign((PrivateKey) privateKey);
} else {
this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom);
}
} catch (InvalidKeyException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
engineInitSign(privateKey, (SecureRandom)null);
}
/** {@inheritDoc} */
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
try {
this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException(ex);
}
}
/** {@inheritDoc} */
protected String engineGetJCEAlgorithmString() {
return this.signatureAlgorithm.getAlgorithm();
}
/** {@inheritDoc} */
protected String engineGetJCEProviderName() {
return this.signatureAlgorithm.getProvider().getName();
}
/** {@inheritDoc} */
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** {@inheritDoc} */
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
) throws XMLSignatureException {
throw new XMLSignatureException("algorithms.CannotUseAlgorithmParameterSpecOnRSA");
}
/**
* Class SignatureECDSASHA1
*
*/
public static class SignatureECDSASHA1 extends SignatureECDSA {
/**
* Constructor SignatureECDSASHA1
*
* @throws XMLSignatureException
*/
public SignatureECDSASHA1() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1;
}
}
/**
* Class SignatureECDSASHA224
*/
public static class SignatureECDSASHA224 extends SignatureECDSA {
/**
* Constructor SignatureECDSASHA224
*
* @throws XMLSignatureException
*/
public SignatureECDSASHA224() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA224;
}
}
/**
* Class SignatureECDSASHA256
*
*/
public static class SignatureECDSASHA256 extends SignatureECDSA {
/**
* Constructor SignatureECDSASHA256
*
* @throws XMLSignatureException
*/
public SignatureECDSASHA256() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256;
}
}
/**
* Class SignatureECDSASHA384
*
*/
public static class SignatureECDSASHA384 extends SignatureECDSA {
/**
* Constructor SignatureECDSASHA384
*
* @throws XMLSignatureException
*/
public SignatureECDSASHA384() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384;
}
}
/**
* Class SignatureECDSASHA512
*
*/
public static class SignatureECDSASHA512 extends SignatureECDSA {
/**
* Constructor SignatureECDSASHA512
*
* @throws XMLSignatureException
*/
public SignatureECDSASHA512() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512;
}
}
/**
* Class SignatureECDSARIPEMD160
*/
public static class SignatureECDSARIPEMD160 extends SignatureECDSA {
/**
* Constructor SignatureECDSARIPEMD160
*
* @throws XMLSignatureException
*/
public SignatureECDSARIPEMD160() throws XMLSignatureException {
super();
}
/** {@inheritDoc} */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_RIPEMD160;
}
}
}

View File

@@ -0,0 +1,101 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.c14n;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
/**
* Class CanonicalizationException
*
*/
public class CanonicalizationException extends XMLSecurityException {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor CanonicalizationException
*
*/
public CanonicalizationException() {
super();
}
public CanonicalizationException(Exception ex) {
super(ex);
}
/**
* Constructor CanonicalizationException
*
* @param msgID
*/
public CanonicalizationException(String msgID) {
super(msgID);
}
/**
* Constructor CanonicalizationException
*
* @param msgID
* @param exArgs
*/
public CanonicalizationException(String msgID, Object exArgs[]) {
super(msgID, exArgs);
}
/**
* Constructor CanonicalizationException
*
* @param originalException
* @param msgID
*/
public CanonicalizationException(Exception originalException, String msgID) {
super(originalException, msgID);
}
@Deprecated
public CanonicalizationException(String msgID, Exception originalException) {
this(originalException, msgID);
}
/**
* Constructor CanonicalizationException
*
* @param originalException
* @param msgID
* @param exArgs
*/
public CanonicalizationException(
Exception originalException, String msgID, Object exArgs[]
) {
super(originalException, msgID, exArgs);
}
@Deprecated
public CanonicalizationException(String msgID, Object exArgs[], Exception originalException) {
this(originalException, msgID, exArgs);
}
}

View File

@@ -0,0 +1,427 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.c14n;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.xml.parsers.DocumentBuilder;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_WithComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclOmitComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315WithComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.CanonicalizerPhysical;
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
/**
*
*/
public class Canonicalizer {
/** The output encoding of canonicalized data */
public static final String ENCODING = StandardCharsets.UTF_8.name();
/**
* XPath Expression for selecting every node and continuous comments joined
* in only one node
*/
public static final String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE =
"(.//. | .//@* | .//namespace::*)";
/**
* The URL defined in XML-SEC Rec for inclusive c14n <b>without</b> comments.
*/
public static final String ALGO_ID_C14N_OMIT_COMMENTS =
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
/**
* The URL defined in XML-SEC Rec for inclusive c14n <b>with</b> comments.
*/
public static final String ALGO_ID_C14N_WITH_COMMENTS =
ALGO_ID_C14N_OMIT_COMMENTS + "#WithComments";
/**
* The URL defined in XML-SEC Rec for exclusive c14n <b>without</b> comments.
*/
public static final String ALGO_ID_C14N_EXCL_OMIT_COMMENTS =
"http://www.w3.org/2001/10/xml-exc-c14n#";
/**
* The URL defined in XML-SEC Rec for exclusive c14n <b>with</b> comments.
*/
public static final String ALGO_ID_C14N_EXCL_WITH_COMMENTS =
ALGO_ID_C14N_EXCL_OMIT_COMMENTS + "WithComments";
/**
* The URI for inclusive c14n 1.1 <b>without</b> comments.
*/
public static final String ALGO_ID_C14N11_OMIT_COMMENTS =
"http://www.w3.org/2006/12/xml-c14n11";
/**
* The URI for inclusive c14n 1.1 <b>with</b> comments.
*/
public static final String ALGO_ID_C14N11_WITH_COMMENTS =
ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
/**
* Non-standard algorithm to serialize the physical representation for XML Encryption
*/
public static final String ALGO_ID_C14N_PHYSICAL =
"http://santuario.apache.org/c14n/physical";
private static Map<String, Class<? extends CanonicalizerSpi>> canonicalizerHash =
new ConcurrentHashMap<String, Class<? extends CanonicalizerSpi>>();
private final CanonicalizerSpi canonicalizerSpi;
private boolean secureValidation;
/**
* Constructor Canonicalizer
*
* @param algorithmURI
* @throws InvalidCanonicalizerException
*/
private Canonicalizer(String algorithmURI) throws InvalidCanonicalizerException {
try {
Class<? extends CanonicalizerSpi> implementingClass =
canonicalizerHash.get(algorithmURI);
canonicalizerSpi = implementingClass.newInstance();
canonicalizerSpi.reset = true;
} catch (Exception e) {
Object exArgs[] = { algorithmURI };
throw new InvalidCanonicalizerException(
e, "signature.Canonicalizer.UnknownCanonicalizer", exArgs
);
}
}
/**
* Method getInstance
*
* @param algorithmURI
* @return a Canonicalizer instance ready for the job
* @throws InvalidCanonicalizerException
*/
public static final Canonicalizer getInstance(String algorithmURI)
throws InvalidCanonicalizerException {
return new Canonicalizer(algorithmURI);
}
/**
* Method register
*
* @param algorithmURI
* @param implementingClass
* @throws AlgorithmAlreadyRegisteredException
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to register the canonicalizer
*/
@SuppressWarnings("unchecked")
public static void register(String algorithmURI, String implementingClass)
throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
JavaUtils.checkRegisterPermission();
// check whether URI is already registered
Class<? extends CanonicalizerSpi> registeredClass =
canonicalizerHash.get(algorithmURI);
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
}
canonicalizerHash.put(
algorithmURI, (Class<? extends CanonicalizerSpi>)
ClassLoaderUtils.loadClass(implementingClass, Canonicalizer.class)
);
}
/**
* Method register
*
* @param algorithmURI
* @param implementingClass
* @throws AlgorithmAlreadyRegisteredException
* @throws SecurityException if a security manager is installed and the
* caller does not have permission to register the canonicalizer
*/
public static void register(String algorithmURI, Class<? extends CanonicalizerSpi> implementingClass)
throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
JavaUtils.checkRegisterPermission();
// check whether URI is already registered
Class<? extends CanonicalizerSpi> registeredClass = canonicalizerHash.get(algorithmURI);
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
}
canonicalizerHash.put(algorithmURI, implementingClass);
}
/**
* This method registers the default algorithms.
*/
public static void registerDefaultAlgorithms() {
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS,
Canonicalizer20010315OmitComments.class
);
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS,
Canonicalizer20010315WithComments.class
);
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS,
Canonicalizer20010315ExclOmitComments.class
);
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS,
Canonicalizer20010315ExclWithComments.class
);
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS,
Canonicalizer11_OmitComments.class
);
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS,
Canonicalizer11_WithComments.class
);
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N_PHYSICAL,
CanonicalizerPhysical.class
);
}
/**
* Method getURI
*
* @return the URI defined for this c14n instance.
*/
public final String getURI() {
return canonicalizerSpi.engineGetURI();
}
/**
* Method getIncludeComments
*
* @return true if the c14n respect the comments.
*/
public boolean getIncludeComments() {
return canonicalizerSpi.engineGetIncludeComments();
}
/**
* This method tries to canonicalize the given bytes. It's possible to even
* canonicalize non-wellformed sequences if they are well-formed after being
* wrapped with a {@code &gt;a&lt;...&gt;/a&lt;}.
*
* @param inputBytes
* @return the result of the canonicalization.
* @throws CanonicalizationException
* @throws java.io.IOException
* @throws javax.xml.parsers.ParserConfigurationException
* @throws org.xml.sax.SAXException
*/
public byte[] canonicalize(byte[] inputBytes)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException, org.xml.sax.SAXException, CanonicalizationException {
Document document = null;
try (InputStream bais = new ByteArrayInputStream(inputBytes)) {
InputSource in = new InputSource(bais);
// needs to validate for ID attribute normalization
DocumentBuilder db = XMLUtils.createDocumentBuilder(true, secureValidation);
/*
* for some of the test vectors from the specification,
* there has to be a validating parser for ID attributes, default
* attribute values, NMTOKENS, etc.
* Unfortunately, the test vectors do use different DTDs or
* even no DTD. So Xerces 1.3.1 fires many warnings about using
* ErrorHandlers.
*
* Text from the spec:
*
* The input octet stream MUST contain a well-formed XML document,
* but the input need not be validated. However, the attribute
* value normalization and entity reference resolution MUST be
* performed in accordance with the behaviors of a validating
* XML processor. As well, nodes for default attributes (declared
* in the ATTLIST with an AttValue but not specified) are created
* in each element. Thus, the declarations in the document type
* declaration are used to help create the canonical form, even
* though the document type declaration is not retained in the
* canonical form.
*/
db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils.IgnoreAllErrorHandler());
document = db.parse(in);
}
return this.canonicalizeSubtree(document);
}
/**
* Canonicalizes the subtree rooted by {@code node}.
*
* @param node The node to canonicalize
* @return the result of the c14n.
*
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node) throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return canonicalizerSpi.engineCanonicalizeSubTree(node);
}
/**
* Canonicalizes the subtree rooted by {@code node}.
*
* @param node
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces)
throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return canonicalizerSpi.engineCanonicalizeSubTree(node, inclusiveNamespaces);
}
/**
* Canonicalizes the subtree rooted by {@code node}.
*
* @param node
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces, boolean propagateDefaultNamespace)
throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return canonicalizerSpi.engineCanonicalizeSubTree(node, inclusiveNamespaces, propagateDefaultNamespace);
}
/**
* Canonicalizes an XPath node set. The {@code xpathNodeSet} is treated
* as a list of XPath nodes, not as a list of subtrees.
*
* @param xpathNodeSet
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
}
/**
* Canonicalizes an XPath node set. The {@code xpathNodeSet} is treated
* as a list of XPath nodes, not as a list of subtrees.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(
NodeList xpathNodeSet, String inclusiveNamespaces
) throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return
canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
}
/**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
}
/**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(
Set<Node> xpathNodeSet, String inclusiveNamespaces
) throws CanonicalizationException {
canonicalizerSpi.secureValidation = secureValidation;
return
canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
}
/**
* Sets the writer where the canonicalization ends. ByteArrayOutputStream
* if none is set.
* @param os
*/
public void setWriter(OutputStream os) {
canonicalizerSpi.setWriter(os);
}
/**
* Returns the name of the implementing {@link CanonicalizerSpi} class
*
* @return the name of the implementing {@link CanonicalizerSpi} class
*/
public String getImplementingCanonicalizerClass() {
return canonicalizerSpi.getClass().getName();
}
/**
* Set the canonicalizer behaviour to not reset.
*/
public void notReset() {
canonicalizerSpi.reset = false;
}
public boolean isSecureValidation() {
return secureValidation;
}
public void setSecureValidation(boolean secureValidation) {
this.secureValidation = secureValidation;
}
}

View File

@@ -0,0 +1,185 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.sun.org.apache.xml.internal.security.c14n;
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
/**
* Base class which all Canonicalization algorithms extend.
*
*/
public abstract class CanonicalizerSpi {
/** Reset the writer after a c14n */
protected boolean reset = false;
protected boolean secureValidation;
/**
* Method canonicalize
*
* @param inputBytes
* @return the c14n bytes.
*
* @throws CanonicalizationException
* @throws java.io.IOException
* @throws javax.xml.parsers.ParserConfigurationException
* @throws org.xml.sax.SAXException
*/
public byte[] engineCanonicalize(byte[] inputBytes)
throws javax.xml.parsers.ParserConfigurationException, java.io.IOException,
org.xml.sax.SAXException, CanonicalizationException {
Document document = null;
try (java.io.InputStream bais = new ByteArrayInputStream(inputBytes)) {
InputSource in = new InputSource(bais);
DocumentBuilder db = XMLUtils.createDocumentBuilder(false, secureValidation);
document = db.parse(in);
}
return this.engineCanonicalizeSubTree(document);
}
/**
* Method engineCanonicalizeXPathNodeSet
*
* @param xpathNodeSet
* @return the c14n bytes
* @throws CanonicalizationException
*/
public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet)
throws CanonicalizationException {
return this.engineCanonicalizeXPathNodeSet(
XMLUtils.convertNodelistToSet(xpathNodeSet)
);
}
/**
* Method engineCanonicalizeXPathNodeSet
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the c14n bytes
* @throws CanonicalizationException
*/
public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet, String inclusiveNamespaces)
throws CanonicalizationException {
return this.engineCanonicalizeXPathNodeSet(
XMLUtils.convertNodelistToSet(xpathNodeSet), inclusiveNamespaces
);
}
/**
* Returns the URI of this engine.
* @return the URI
*/
public abstract String engineGetURI();
/**
* Returns true if comments are included
* @return true if comments are included
*/
public abstract boolean engineGetIncludeComments();
/**
* C14n a nodeset
*
* @param xpathNodeSet
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
throws CanonicalizationException;
/**
* C14n a nodeset
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeXPathNodeSet(
Set<Node> xpathNodeSet, String inclusiveNamespaces
) throws CanonicalizationException;
/**
* C14n a node tree.
*
* @param rootNode
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeSubTree(Node rootNode)
throws CanonicalizationException;
/**
* C14n a node tree.
*
* @param rootNode
* @param inclusiveNamespaces
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces)
throws CanonicalizationException;
/**
* C14n a node tree.
*
* @param rootNode
* @param inclusiveNamespaces
* @param propagateDefaultNamespace If true the default namespace will be propagated to the c14n-ized root element
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeSubTree(
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace)
throws CanonicalizationException;
/**
* Sets the writer where the canonicalization ends. ByteArrayOutputStream if
* none is set.
* @param os
*/
public abstract void setWriter(OutputStream os);
public boolean isSecureValidation() {
return secureValidation;
}
public void setSecureValidation(boolean secureValidation) {
this.secureValidation = secureValidation;
}
}

Some files were not shown because too many files have changed in this diff Show More