< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncHere.java

Print this page


   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Oct 2017
   4  */
   5 /**
   6  * Licensed to the Apache Software Foundation (ASF) under one
   7  * or more contributor license agreements. See the NOTICE file
   8  * distributed with this work for additional information
   9  * regarding copyright ownership. The ASF licenses this file
  10  * to you under the Apache License, Version 2.0 (the
  11  * "License"); you may not use this file except in compliance
  12  * with the License. You may obtain a copy of the License at
  13  *
  14  * http://www.apache.org/licenses/LICENSE-2.0
  15  *
  16  * Unless required by applicable law or agreed to in writing,
  17  * software distributed under the License is distributed on an
  18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19  * KIND, either express or implied. See the License for the
  20  * specific language governing permissions and limitations
  21  * under the License.
  22  */
  23 package com.sun.org.apache.xpath.internal.functions;
  24 
  25 import com.sun.org.apache.xml.internal.dtm.DTM;
  26 import com.sun.org.apache.xml.internal.utils.QName;
  27 import com.sun.org.apache.xpath.internal.NodeSetDTM;
  28 import com.sun.org.apache.xpath.internal.XPathContext;
  29 import com.sun.org.apache.xpath.internal.objects.XNodeSet;
  30 import com.sun.org.apache.xpath.internal.objects.XObject;
  31 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
  32 import java.util.List;
  33 import javax.xml.transform.TransformerException;
  34 import org.w3c.dom.Document;
  35 import org.w3c.dom.Node;
  36 
  37 /**
  38  * Execute the XML Signature here() function.


  39  */
  40 public final class FuncHere extends Function {
  41 
  42     private static final long serialVersionUID = 4328660760070034592L;
  43 
  44     @Override
  45     public XObject execute(XPathContext xctxt) throws TransformerException {
  46         Node xpathOwnerNode = (Node)xctxt.getOwnerObject();
  47         if (xpathOwnerNode == null) {
  48             return null;
  49         }
  50 
  51         int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);
  52         int currentNode = xctxt.getCurrentNode();
  53         DTM dtm = xctxt.getDTM(currentNode);
  54         int docContext = dtm.getDocument();
  55 
  56         if (docContext == DTM.NULL) {
  57             error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
  58         }


   1 /*
   2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /**
   5  * Licensed to the Apache Software Foundation (ASF) under one
   6  * or more contributor license agreements. See the NOTICE file
   7  * distributed with this work for additional information
   8  * regarding copyright ownership. The ASF licenses this file
   9  * to you under the Apache License, Version 2.0 (the
  10  * "License"); you may not use this file except in compliance
  11  * with 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,
  16  * software distributed under the License is distributed on an
  17  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18  * KIND, either express or implied. See the License for the
  19  * specific language governing permissions and limitations
  20  * under the License.
  21  */
  22 package com.sun.org.apache.xpath.internal.functions;
  23 
  24 import com.sun.org.apache.xml.internal.dtm.DTM;
  25 import com.sun.org.apache.xml.internal.utils.QName;
  26 import com.sun.org.apache.xpath.internal.NodeSetDTM;
  27 import com.sun.org.apache.xpath.internal.XPathContext;
  28 import com.sun.org.apache.xpath.internal.objects.XNodeSet;
  29 import com.sun.org.apache.xpath.internal.objects.XObject;
  30 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
  31 import java.util.List;
  32 import javax.xml.transform.TransformerException;
  33 import org.w3c.dom.Document;
  34 import org.w3c.dom.Node;
  35 
  36 /**
  37  * Execute the XML Signature here() function.
  38  *
  39  * @LastModified: Oct 2017
  40  */
  41 public final class FuncHere extends Function {
  42 
  43     private static final long serialVersionUID = 4328660760070034592L;
  44 
  45     @Override
  46     public XObject execute(XPathContext xctxt) throws TransformerException {
  47         Node xpathOwnerNode = (Node)xctxt.getOwnerObject();
  48         if (xpathOwnerNode == null) {
  49             return null;
  50         }
  51 
  52         int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);
  53         int currentNode = xctxt.getCurrentNode();
  54         DTM dtm = xctxt.getDTM(currentNode);
  55         int docContext = dtm.getDocument();
  56 
  57         if (docContext == DTM.NULL) {
  58             error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
  59         }


< prev index next >