You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jy...@apache.org on 2006/11/08 21:43:56 UTC
svn commit: r472634 -
/xalan/java/trunk/src/org/apache/xml/utils/DOMBuilder.java
Author: jycli
Date: Wed Nov 8 12:43:55 2006
New Revision: 472634
URL: http://svn.apache.org/viewvc?view=rev&rev=472634
Log:
Fixed bug XALANJ-2091
Added namespace nodes to the DOM tree
Modified:
xalan/java/trunk/src/org/apache/xml/utils/DOMBuilder.java
Modified: xalan/java/trunk/src/org/apache/xml/utils/DOMBuilder.java
URL: http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xml/utils/DOMBuilder.java?view=diff&rev=472634&r1=472633&r2=472634
==============================================================================
--- xalan/java/trunk/src/org/apache/xml/utils/DOMBuilder.java (original)
+++ xalan/java/trunk/src/org/apache/xml/utils/DOMBuilder.java Wed Nov 8 12:43:55 2006
@@ -21,6 +21,7 @@
package org.apache.xml.utils;
import java.util.Stack;
+import java.util.Vector;
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
@@ -63,7 +64,10 @@
/** Vector of element nodes */
protected Stack m_elemStack = new Stack();
-
+
+ /** Namespace support */
+ protected Vector m_prefixMappings = new Vector();
+
/**
* DOMBuilder instance constructor... it will add the DOM nodes
* to the document fragment.
@@ -361,7 +365,28 @@
elem.setAttributeNS(attrNS,attrQName, atts.getValue(i));
}
}
+
+ /*
+ * Adding namespace nodes to the DOM tree;
+ */
+ int nDecls = m_prefixMappings.size();
+
+ String prefix, declURL;
+
+ for (int i = 0; i < nDecls; i += 2)
+ {
+ prefix = (String) m_prefixMappings.elementAt(i);
+ if (prefix == null)
+ continue;
+
+ declURL = (String) m_prefixMappings.elementAt(i + 1);
+
+ elem.setAttributeNS("http://www.w3.org/2000/xmlns/", prefix, declURL);
+ }
+
+ m_prefixMappings.clear();
+
// append(elem);
m_elemStack.push(elem);
@@ -730,29 +755,11 @@
public void startPrefixMapping(String prefix, String uri)
throws org.xml.sax.SAXException
{
-
- /*
- // Not sure if this is needed or wanted
- // Also, it fails in the stree.
- if((null != m_currentNode)
- && (m_currentNode.getNodeType() == Node.ELEMENT_NODE))
- {
- String qname;
- if(((null != prefix) && (prefix.length() == 0))
- || (null == prefix))
- qname = "xmlns";
- else
- qname = "xmlns:"+prefix;
-
- Element elem = (Element)m_currentNode;
- String val = elem.getAttribute(qname); // Obsolete, should be DOM2...?
- if(val == null)
- {
- elem.setAttributeNS("http://www.w3.org/XML/1998/namespace",
- qname, uri);
- }
- }
- */
+ if(null == prefix || prefix.equals(""))
+ prefix = "xmlns";
+ else prefix = "xmlns:"+prefix;
+ m_prefixMappings.addElement(prefix);
+ m_prefixMappings.addElement(uri);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org