Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix DOM2DTM to work in J9 #1760

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ ext/java/nokogiri/internals/XalanDTMManagerPatch.java
ext/java/nokogiri/internals/XmlDeclHandler.java
ext/java/nokogiri/internals/XmlDomParserContext.java
ext/java/nokogiri/internals/XmlSaxParser.java
ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java
ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java
ext/java/nokogiri/internals/c14n/AttrCompare.java
ext/java/nokogiri/internals/c14n/C14nHelper.java
ext/java/nokogiri/internals/c14n/CanonicalFilter.java
Expand Down Expand Up @@ -108,7 +110,6 @@ ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java
ext/java/nokogiri/internals/c14n/NodeFilter.java
ext/java/nokogiri/internals/c14n/UtfHelpper.java
ext/java/nokogiri/internals/c14n/XMLUtils.java
ext/java/org/apache/xml/dtm/ref/dom2dtm/DOM2DTMExt.java
ext/nokogiri/depend
ext/nokogiri/extconf.rb
ext/nokogiri/html_document.c
Expand Down
18 changes: 12 additions & 6 deletions ext/java/nokogiri/internals/XalanDTMManagerPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
package nokogiri.internals;

import org.apache.xml.dtm.DTM;
import nokogiri.internals.dom2dtm.DOM2DTM;
import nokogiri.internals.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode;
import org.apache.xml.dtm.DTMWSFilter;
import org.apache.xml.dtm.ref.dom2dtm.DOM2DTMExt;
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -80,6 +81,11 @@ public final class XalanDTMManagerPatch extends org.apache.xml.dtm.ref.DTMManage
if (handle != DTM.NULL) {
return handle;
}
} else if (thisDTM instanceof DOM2DTM) {
int handle = ((DOM2DTM) thisDTM).getHandleOfNode(node);
if (handle != DTM.NULL) {
return handle;
}
}
}

Expand Down Expand Up @@ -107,11 +113,12 @@ public final class XalanDTMManagerPatch extends org.apache.xml.dtm.ref.DTMManage
for (; p != null; p = p.getParentNode()) root = p;

// DOM2DTM dtm = (DOM2DTM) getDTM(new DOMSource(root), false, null);
DOM2DTMExt dtm = getDTMExt(new DOMSource(root), false, null/*, true, true*/);
DOM2DTM dtm = getDTM(new DOMSource(root), false, null/*, true, true*/);

int handle;

if (node instanceof org.apache.xml.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode) {
if (node instanceof org.apache.xml.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode
|| node instanceof 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.
Expand Down Expand Up @@ -153,12 +160,11 @@ public final class XalanDTMManagerPatch extends org.apache.xml.dtm.ref.DTMManage
return handle;
}

private DOM2DTMExt getDTMExt(DOMSource source, boolean unique, DTMWSFilter whiteSpaceFilter/*, boolean incremental, boolean doIndexing*/) {
private DOM2DTM getDTM(DOMSource source, boolean unique, DTMWSFilter whiteSpaceFilter/*, boolean incremental, boolean doIndexing*/) {
int dtmPos = getFirstFreeDTMID();
int documentID = dtmPos << IDENT_DTM_NODE_BITS;

//DOM2DTM dtm = new DOM2DTM(this, source, documentID, whiteSpaceFilter, m_xsf, true);
DOM2DTMExt dtm = new DOM2DTMExt(this, source, documentID, whiteSpaceFilter, m_xsf, true);
DOM2DTM dtm = new DOM2DTM(this, source, documentID, whiteSpaceFilter, m_xsf, true);

addDTM(dtm, dtmPos, 0);
return dtm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: DOM2DTM.java 478671 2006-11-23 21:00:31Z minchau $
*/
package org.apache.xml.dtm.ref.dom2dtm;
package nokogiri.internals.dom2dtm;

import javax.xml.transform.SourceLocator;
import javax.xml.transform.dom.DOMSource;
Expand All @@ -30,7 +27,6 @@
import org.apache.xml.dtm.ref.DTMManagerDefault;
import org.apache.xml.dtm.ref.ExpandedNameTable;
import org.apache.xml.dtm.ref.IncrementalSAXSource;
//import org.apache.xml.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode;
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
import org.apache.xml.utils.FastStringBuffer;
Expand Down Expand Up @@ -62,7 +58,7 @@
* mutation. If you alter the DOM after wrapping DOM2DTM around it,
* all bets are off.
* */
public class DOM2DTMExt extends DTMDefaultBaseIterators
public class DOM2DTM extends DTMDefaultBaseIterators
{
// static final boolean JJK_DEBUG=false;
// static final boolean JJK_NEWCODE=true;
Expand Down Expand Up @@ -114,7 +110,7 @@ public class DOM2DTMExt extends DTMDefaultBaseIterators
* @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
*/
public DOM2DTMExt(DTMManager mgr, DOMSource domSource,
public DOM2DTM(DTMManager mgr, DOMSource domSource,
int dtmIdentity, DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing)
Expand Down
Loading