public class TransformImplXPath2 extends Transform
| Modifier and Type | Class and Description |
|---|---|
protected class |
TransformImplXPath2.NSDeclaration
Auxilary class representing a XML namespace declaration structure.
|
protected class |
TransformImplXPath2.XPathFilter
Auxiliary class representing an XPath filter of this transform.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.ArrayList |
currentNodeAncestors_
The ancestors of the current node being processed by this transform.
|
protected static java.lang.String |
DEFAULT_ALGORITHM_URI_
The default algorithm URI for this algorithm implementation.
|
protected static java.lang.String |
FILTER_ATTRIBUTE_NAME_
The name of the filter attribute in the parameter element of this transform.
|
static int |
FILTER_MODE_INTERSECT_
Filter mode "set intersection".
|
static int |
FILTER_MODE_SUBTRACT_
Filter mode "set subtraction".
|
static int |
FILTER_MODE_UNION_
Filter mode "set union".
|
static java.lang.String[] |
FILTER_MODE_VALUES_
The possible values for the filter mode attribute of the XPath filter parameter element.
|
protected static java.lang.String |
NAMESPACE_PREFIX_
The namespace prefix to be used in the
XPath parameter element. |
protected static java.lang.String |
NAMESPACE_URI_
The namespace URI used for the transform's
XPath parameter element. |
protected static java.lang.String |
PARAMETER_ELEMENT_NAME_
The name of the parameter element for this transform.
|
protected java.util.List |
xPathFilters_
The list of XPath filters of this transform.
|
inputNodeSet_, inputOctetStream_, inputURI_| Constructor and Description |
|---|
TransformImplXPath2()
Standard constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
addToFilterNodeList(org.w3c.dom.Node node)
Tests if the specified node has to be added to the filter result node set.
|
void |
addXPathFilter(java.lang.String xPath,
int mode,
java.util.Map nSDeclarations)
Adds an XPath filter to the sequence of filters which are computed in order to get the filter node set.
|
protected void |
checkBackingDOM(java.lang.String xPath,
org.w3c.dom.Element xPath2ParamElem)
In case that the specified xPath expression contains the here() function, checks if the input
node set is backed by the same DOM instance as the specified DOM representation of the XPath Filter 2
parameter element.
|
protected int |
getLastUnionFilterSetSExpandedPos(org.w3c.dom.Node node)
Determines the position of the last union filter, whose expanded set S contains the specified node.
|
org.w3c.dom.NodeList |
getXPath2Elements()
Gets the DOM elements of the XPath elements of this transform.
|
protected boolean |
isInAllSubsequentIntersectFilterSetSExpanded(int startFilterPos,
org.w3c.dom.Node node)
Tests if the specifed node is contained in the expanded set S of all intersect filters having a
position greater or equal to
startFilterPos. |
protected boolean |
isInFilterResultSetSExpanded(int filterPos,
org.w3c.dom.Node node)
Tests if the specified node is in the expanded set S of the filter with the specified position.
|
protected boolean |
isInNoSubsequentSubtractFilterSetSExpanded(int startFilterPos,
org.w3c.dom.Node node)
Tests if the specified node is not contained in the expanded set S of any subtract filter having a
position greater or equal to
startFilterPos. |
protected java.util.HashSet |
nodeList2HashSet(org.w3c.dom.NodeList nodeList)
Generates a hash set from the specified node list
|
protected void |
setAsParent(org.w3c.dom.Node node)
Adapts the specified ancestor list in a way that the specified node is the parent.
|
void |
setParameters(org.w3c.dom.Element transformElement)
Sets the parameters for this XPath Filter 2.0 transform implementation.
|
org.w3c.dom.Element |
toElement(org.w3c.dom.Document signatureDOMDoc)
Returns the DOM element representation of the transform.
|
java.lang.Object |
transform()
Computes the transform result for the previously specified input.
|
distributeNSDeclarations, setInput, setInput, skipStylesheetElem, withdrawDistributedNSDeclarationspublic static final int FILTER_MODE_INTERSECT_
public static final int FILTER_MODE_SUBTRACT_
public static final int FILTER_MODE_UNION_
public static final java.lang.String[] FILTER_MODE_VALUES_
protected static final java.lang.String DEFAULT_ALGORITHM_URI_
protected static final java.lang.String NAMESPACE_URI_
XPath parameter element.protected static final java.lang.String NAMESPACE_PREFIX_
XPath parameter element.protected static final java.lang.String PARAMETER_ELEMENT_NAME_
protected static final java.lang.String FILTER_ATTRIBUTE_NAME_
protected java.util.List xPathFilters_
protected java.util.ArrayList currentNodeAncestors_
public TransformImplXPath2()
http://www.w3.org/2002/06/xmldsig-filter2.public void setParameters(org.w3c.dom.Element transformElement)
throws AlgorithmException
XPath parameter elements representing the XPath filters
the transform is composed of. Each parameter element contains an XPath expression to be processed as
its character data and an attribute named Filter, providing the operation mode of the
filter (one of intersect, subtract, or union. The namespace
attributes in scope for each parameter element will be used as the namespace context at evaluation of
the XPath expression the parameter element contains.setParameters in class AlgorithmtransformElement - The DOM element representation of the transform, as it will be found by IXSIL
in the XML signature.AlgorithmException - if no XPath parameter element can be found, or if an XPath parameter
element does not contain any character data, or if setting the parameter
fails for any other reason.public void addXPathFilter(java.lang.String xPath,
int mode,
java.util.Map nSDeclarations)
xPath - The XPath expression of the filter. Must not be null or an empty string.mode - The mode of the filter (see FILTER_MODE_INTERSECT_,
FILTER_MODE_SUBTRACT_ and FILTER_MODE_UNION_).nSDeclarations - A map of namespace declarations which are used as additonal part of the
space context at evaluation of this filter's XPath expression. If a namespace
prefix is used in this filter's XPath expression which is not in scope for the
XPath element representing this XPath filter, it must be present in this set.
The key of an entry in this map must be a valid namespace prefix String, the corresponding value must be the associated
namespace URI. The map may be null.public org.w3c.dom.NodeList getXPath2Elements()
public org.w3c.dom.Element toElement(org.w3c.dom.Document signatureDOMDoc)
throws AlgorithmException
toElement in class AlgorithmsignatureDOMDoc - The DOM document which should be used to create necessary DOM nodes.AlgorithmException - if no identifying URI has been specified for this transform, or if no
transform parameters (see addXPathFilter(java.lang.String, int, java.util.Map) have been specified.public java.lang.Object transform()
throws AlgorithmException
transform in class TransformAlgorithmException - if no input has been set previously, or if no parameters have been
set previously, or if converting a input octet stream into a XPath node
set input fails, or if performing the transform fails for any reason.protected int getLastUnionFilterSetSExpandedPos(org.w3c.dom.Node node)
node - The node to be tested.-1 of no such filter exists.protected boolean isInAllSubsequentIntersectFilterSetSExpanded(int startFilterPos,
org.w3c.dom.Node node)
startFilterPos.startFilterPos - The filter position at which to start this test.node - The node to be tested.true if and only if the specified node is contained in all intersect filters as
specified above, or if there are no intersect filters.protected boolean isInNoSubsequentSubtractFilterSetSExpanded(int startFilterPos,
org.w3c.dom.Node node)
startFilterPos.startFilterPos - The filter position at which to start this test.node - The node to be tested.true if and only if the specified node is not contained in any intersect filters
as specified above, or if there are no subtract filters.protected boolean isInFilterResultSetSExpanded(int filterPos,
org.w3c.dom.Node node)
filterPos - The position of the filter whose set S should be investigated.node - The node to be tested.true if and only if the specified node is in the expanded set S of the specified
filter.protected void setAsParent(org.w3c.dom.Node node)
node - The new parent.protected boolean addToFilterNodeList(org.w3c.dom.Node node)
node - The node to be tested.true if and only if the node has to be added to the filter result node set.protected java.util.HashSet nodeList2HashSet(org.w3c.dom.NodeList nodeList)
nodeList - The original node list.protected void checkBackingDOM(java.lang.String xPath,
org.w3c.dom.Element xPath2ParamElem)
throws AlgorithmException
xPath - The xPath expression.xPath2ParamElem - The XPath Filter 2 parameter element.AlgorithmException - if the condition specified above is not met.