< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/DTMManagerDefault.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xml.internal.dtm.ref;
  23 


 554       Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
 555       for (; p != null; p = p.getParentNode())
 556       {
 557         root = p;
 558       }
 559 
 560       DOM2DTM dtm = (DOM2DTM) getDTM(new javax.xml.transform.dom.DOMSource(root),
 561                                                                                                                                                  false, null, true, true);
 562 
 563       int handle;
 564 
 565       if(node instanceof com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode)
 566       {
 567                                 // Can't return the same node since it's unique to a specific DTM,
 568                                 // but can return the equivalent node -- find the corresponding
 569                                 // Document Element, then ask it for the xml: namespace decl.
 570                                 handle=dtm.getHandleOfNode(((org.w3c.dom.Attr)node).getOwnerElement());
 571                                 handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
 572       }
 573       else
 574                                 handle = ((DOM2DTM)dtm).getHandleOfNode(node);
 575 
 576       if(DTM.NULL == handle)
 577         throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COULD_NOT_RESOLVE_NODE, null)); //"Could not resolve the node to a handle!");
 578 
 579       return handle;
 580     }
 581   }
 582 
 583   /**
 584    * This method returns the SAX2 parser to use with the InputSource
 585    * obtained from this URI.
 586    * It may return null if any SAX2-conformant XML parser can be used,
 587    * or if getInputSource() will also return null. The parser must
 588    * be free for use (i.e., not currently in use for another parse().
 589    * After use of the parser is completed, the releaseXMLReader(XMLReader)
 590    * must be called.
 591    *
 592    * @param inputSource The value returned from the URIResolver.
 593    * @return  a SAX2 XMLReader to use to resolve the inputSource argument.
 594    *


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xml.internal.dtm.ref;
  23 


 554       Node p = (root.getNodeType() == Node.ATTRIBUTE_NODE) ? ((org.w3c.dom.Attr)root).getOwnerElement() : root.getParentNode();
 555       for (; p != null; p = p.getParentNode())
 556       {
 557         root = p;
 558       }
 559 
 560       DOM2DTM dtm = (DOM2DTM) getDTM(new javax.xml.transform.dom.DOMSource(root),
 561                                                                                                                                                  false, null, true, true);
 562 
 563       int handle;
 564 
 565       if(node instanceof com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode)
 566       {
 567                                 // Can't return the same node since it's unique to a specific DTM,
 568                                 // but can return the equivalent node -- find the corresponding
 569                                 // Document Element, then ask it for the xml: namespace decl.
 570                                 handle=dtm.getHandleOfNode(((org.w3c.dom.Attr)node).getOwnerElement());
 571                                 handle=dtm.getAttributeNode(handle,node.getNamespaceURI(),node.getLocalName());
 572       }
 573       else
 574                                 handle = dtm.getHandleOfNode(node);
 575 
 576       if(DTM.NULL == handle)
 577         throw new RuntimeException(XMLMessages.createXMLMessage(XMLErrorResources.ER_COULD_NOT_RESOLVE_NODE, null)); //"Could not resolve the node to a handle!");
 578 
 579       return handle;
 580     }
 581   }
 582 
 583   /**
 584    * This method returns the SAX2 parser to use with the InputSource
 585    * obtained from this URI.
 586    * It may return null if any SAX2-conformant XML parser can be used,
 587    * or if getInputSource() will also return null. The parser must
 588    * be free for use (i.e., not currently in use for another parse().
 589    * After use of the parser is completed, the releaseXMLReader(XMLReader)
 590    * must be called.
 591    *
 592    * @param inputSource The value returned from the URIResolver.
 593    * @return  a SAX2 XMLReader to use to resolve the inputSource argument.
 594    *


< prev index next >