You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by ra...@apache.org on 2004/11/18 23:50:26 UTC

cvs commit: xml-security/src/org/apache/xml/security/c14n/implementations Canonicalizer20010315Excl.java

raul        2004/11/18 14:50:26

  Modified:    src/org/apache/xml/security/c14n/implementations
                        Canonicalizer20010315Excl.java
  Log:
  Transforms all the Constants references to a own static member, reduce memory needs & improves performance.
  Use the same mechanism for xmlns definition to the same using in inclusive, fix a bug when xmlns is inside the inclusive-mappings.
  
  Revision  Changes    Path
  1.18      +14 -13    xml-security/src/org/apache/xml/security/c14n/implementations/Canonicalizer20010315Excl.java
  
  Index: Canonicalizer20010315Excl.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/c14n/implementations/Canonicalizer20010315Excl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Canonicalizer20010315Excl.java	24 Sep 2004 20:54:29 -0000	1.17
  +++ Canonicalizer20010315Excl.java	18 Nov 2004 22:50:26 -0000	1.18
  @@ -52,6 +52,7 @@
         * the inclusive namespaces.
         */
       TreeSet _inclusiveNSSet = null;
  +    static final String XMLNS_URI=Constants.NamespaceSpecNS;
   	/**
   	 * Constructor Canonicalizer20010315Excl
   	 * 
  @@ -127,7 +128,7 @@
   			String NName=N.getLocalName();
   			String NNodeValue=N.getNodeValue();
   						
  -			if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
  +			if (!XMLNS_URI.equals(N.getNamespaceURI())) {
   				//Not a namespace definition.
   				//The Element is output element, add his prefix(if used) to visibyUtilized
   				String prefix = N.getPrefix();
  @@ -223,8 +224,6 @@
   			visiblyUtilized =  (Set) this._inclusiveNSSet.clone();
   		}
   		
  -		//Is the xmlns defined in this node?
  -		boolean xmlnsDef=false;
   		for (int i = 0; i < attrsLength; i++) {
   			Attr N = (Attr) attrs.item(i);
   			String NName=N.getLocalName();
  @@ -234,7 +233,7 @@
   				continue;
   			}			
   						
  -			if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
  +			if (!XMLNS_URI.equals(N.getNamespaceURI())) {
   				//Not a namespace definition.
   				if (isOutputElement) {
   					//The Element is output element, add his prefix(if used) to visibyUtilized
  @@ -249,9 +248,6 @@
   			}
   						
   			
  -			if (XMLNS.equals(NName)) {				
  -				xmlnsDef=true;
  -			}
   			if (ns.addMapping(NName, NNodeValue,N)) {
                   //New definiton check if it is relative
                   if (C14nHelper.namespaceIsRelative(NNodeValue)) {
  @@ -262,11 +258,16 @@
                   }    
               }
   		}
  -		if (!xmlnsDef ) {
  -			ns.addMapping(XMLNS,"",nullNode);
  -		}
  -		
  -		if (isOutputElement) {			
  +
  +		if (isOutputElement) {	               
  +           //The element is visible, handle the xmlns definition    
  +           Attr xmlns = E.getAttributeNodeNS(XMLNS_URI, XMLNS);
  +           if ((xmlns!=null) &&  (!this._xpathNodeSet.contains(xmlns))) {
  +              //There is a definition but the xmlns is not selected by the xpath.
  +              //then xmlns=""
  +              ns.addMapping(XMLNS,"",nullNode);                               
  +            }
  +
   			if (E.getNamespaceURI() != null) {
   				String prefix = E.getPrefix();
   				if ((prefix == null) || (prefix.length() == 0)) {