KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > transforms > implementations > FuncHereContext


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package com.sun.org.apache.xml.internal.security.transforms.implementations;
18
19
20
21 import com.sun.org.apache.xml.internal.dtm.DTMManager;
22 import com.sun.org.apache.xml.internal.security.utils.I18n;
23 import com.sun.org.apache.xpath.internal.CachedXPathAPI;
24 import com.sun.org.apache.xpath.internal.XPathContext;
25 import org.w3c.dom.Node JavaDoc;
26
27
28 /**
29  * {@link FuncHereContext} extends {@link XPathContext} for supplying context
30  * for the <CODE>here()</CODE> function. The here() function needs to know
31  * <I>where</I> in an XML instance the XPath text string appeared. This can be
32  * in {@link org.w3c.dom.Text}, {@link org.w3c.dom.Attr}ibutes and {@ProcessingInstrinction} nodes. The
33  * correct node must be supplied to the constructor of {@link FuncHereContext}.
34  * The supplied Node MUST contain the XPath which is to be executed.
35  *
36  * <PRE>
37  * From: Scott_Boag\@lotus.com
38  * To: Christian Geuer-Pollmann <maillist\@nue.et-inf.uni-siegen.de>
39  * CC: xalan-dev@xml.apache.org
40  * Subject: Re: Cleanup of XPathContext & definition of XSLTContext
41  * Date: Tue, 21 Aug 2001 18:36:24 -0400
42  *
43  * > My point is to say to get this baby to run, the XPath must have a
44  * > possibility to retrieve the information where itself occured in a
45  * > document.
46  *
47  * It sounds to me like you have to derive an XMLSigContext from the
48  * XPathContext?
49  *
50  * > and supplied the Node which contains the xpath string as "owner". Question:
51  * > Is this the correct use of the owner object? It works, but I don't know
52  * > whether this is correct from the xalan-philosophy...
53  *
54  * Philosophically it's fine. The owner is the TransformerImpl if XPath is
55  * running under XSLT. If it is not running under XSLT, it can be whatever
56  * you want.
57  *
58  * -scott
59  * </PRE>
60  *
61  * @author $Author: raul $
62  * @see com.sun.org.apache.xml.internal.security.transforms.implementations.FuncHere
63  * @see com.sun.org.apache.xml.internal.security.utils.XPathFuncHereAPI
64  * @see <A HREF="http://www.w3.org/Signature/Drafts/xmldsig-core/Overview.html#function-here">XML Signature - The here() function</A>
65  */

66 public class FuncHereContext extends XPathContext {
67
68    /**
69     * This constuctor is disabled because if we use the here() function we
70     * <I>always</I> need to know in which node the XPath occured.
71     */

72    private FuncHereContext() {}
73
74    /**
75     * Constructor FuncHereContext
76     *
77     * @param owner
78     */

79    public FuncHereContext(Node JavaDoc owner) {
80       super(owner);
81    }
82
83    /**
84     * Constructor FuncHereContext
85     *
86     * @param owner
87     * @param xpathContext
88     */

89    public FuncHereContext(Node JavaDoc owner, XPathContext xpathContext) {
90
91       super(owner);
92
93       try {
94          super.m_dtmManager = xpathContext.getDTMManager();
95       } catch (IllegalAccessError JavaDoc iae) {
96          throw new IllegalAccessError JavaDoc(I18n.translate("endorsed.jdk1.4.0")
97                                       + " Original message was \""
98                                       + iae.getMessage() + "\"");
99       }
100    }
101
102    /**
103     * Constructor FuncHereContext
104     *
105     * @param owner
106     * @param previouslyUsed
107     */

108    public FuncHereContext(Node JavaDoc owner, CachedXPathAPI previouslyUsed) {
109
110       super(owner);
111
112       try {
113          super.m_dtmManager = previouslyUsed.getXPathContext().getDTMManager();
114       } catch (IllegalAccessError JavaDoc iae) {
115          throw new IllegalAccessError JavaDoc(I18n.translate("endorsed.jdk1.4.0")
116                                       + " Original message was \""
117                                       + iae.getMessage() + "\"");
118       }
119    }
120
121    /**
122     * Constructor FuncHereContext
123     *
124     * @param owner
125     * @param dtmManager
126     */

127    public FuncHereContext(Node JavaDoc owner, DTMManager dtmManager) {
128
129       super(owner);
130
131       try {
132          super.m_dtmManager = dtmManager;
133       } catch (IllegalAccessError JavaDoc iae) {
134          throw new IllegalAccessError JavaDoc(I18n.translate("endorsed.jdk1.4.0")
135                                       + " Original message was \""
136                                       + iae.getMessage() + "\"");
137       }
138    }
139 }
140
Popular Tags