1 /*
2 * Copyright (c) 2013, 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 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.xpath.internal.jaxp;
23
120 new Object[] { myQName.toString() } );
121 throw new XPathFunctionException ( fmsg );
122 }
123
124 // Assuming user is passing all the needed parameters ( including
125 // default values )
126 int arity = argVec.size();
127
128 javax.xml.xpath.XPathFunction xpathFunction =
129 resolver.resolveFunction ( myQName, arity );
130
131 // not using methodKey
132 List<Object> argList = new ArrayList<>( arity);
133 for ( int i=0; i<arity; i++ ) {
134 XObject argument = argVec.get( i );
135 // XNodeSet object() returns NodeVector and not NodeList
136 // Explicitly getting NodeList by using nodelist()
137 if ( argument instanceof XNodeSet ) {
138 argList.add ( i, ((XNodeSet)argument).nodelist() );
139 } else if ( argument instanceof XObject ) {
140 Object passedArgument = ((XObject)argument).object();
141 argList.add ( i, passedArgument );
142 } else {
143 argList.add ( i, argument );
144 }
145 }
146
147 return ( xpathFunction.evaluate ( argList ));
148 } catch ( XPathFunctionException xfe ) {
149 // If we get XPathFunctionException then we want to terminate
150 // further execution by throwing WrappedRuntimeException
151 throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException ( xfe );
152 } catch ( Exception e ) {
153 throw new javax.xml.transform.TransformerException ( e );
154 }
155
156 }
157
158 /**
159 * Execute the extension function.
160 */
171 // feature is set then invocation of extension functions need to
172 // throw XPathFunctionException
173 if ( extensionInvocationDisabled ) {
174 String fmsg = XSLMessages.createXPATHMessage(
175 XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
176 new Object[] { myQName.toString() } );
177 throw new XPathFunctionException ( fmsg );
178 }
179
180 XPathFunction xpathFunction =
181 resolver.resolveFunction( myQName, arity );
182
183 List<Object> argList = new ArrayList<>( arity);
184 for ( int i=0; i<arity; i++ ) {
185 XObject argument = argVec.get( i );
186 // XNodeSet object() returns NodeVector and not NodeList
187 // Explicitly getting NodeList by using nodelist()
188 if ( argument instanceof XNodeSet ) {
189 argList.add ( i, ((XNodeSet)argument).nodelist() );
190 } else if ( argument instanceof XObject ) {
191 Object passedArgument = ((XObject)argument).object();
192 argList.add ( i, passedArgument );
193 } else {
194 argList.add ( i, argument );
195 }
196 }
197
198 return ( xpathFunction.evaluate ( argList ));
199
200 } catch ( XPathFunctionException xfe ) {
201 // If we get XPathFunctionException then we want to terminate
202 // further execution by throwing WrappedRuntimeException
203 throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException ( xfe );
204 } catch ( Exception e ) {
205 throw new javax.xml.transform.TransformerException ( e );
206 }
207 }
208
209 }
|
1 /*
2 * Copyright (c) 2013, 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.xpath.internal.jaxp;
23
120 new Object[] { myQName.toString() } );
121 throw new XPathFunctionException ( fmsg );
122 }
123
124 // Assuming user is passing all the needed parameters ( including
125 // default values )
126 int arity = argVec.size();
127
128 javax.xml.xpath.XPathFunction xpathFunction =
129 resolver.resolveFunction ( myQName, arity );
130
131 // not using methodKey
132 List<Object> argList = new ArrayList<>( arity);
133 for ( int i=0; i<arity; i++ ) {
134 XObject argument = argVec.get( i );
135 // XNodeSet object() returns NodeVector and not NodeList
136 // Explicitly getting NodeList by using nodelist()
137 if ( argument instanceof XNodeSet ) {
138 argList.add ( i, ((XNodeSet)argument).nodelist() );
139 } else if ( argument instanceof XObject ) {
140 Object passedArgument = argument.object();
141 argList.add ( i, passedArgument );
142 } else {
143 argList.add ( i, argument );
144 }
145 }
146
147 return ( xpathFunction.evaluate ( argList ));
148 } catch ( XPathFunctionException xfe ) {
149 // If we get XPathFunctionException then we want to terminate
150 // further execution by throwing WrappedRuntimeException
151 throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException ( xfe );
152 } catch ( Exception e ) {
153 throw new javax.xml.transform.TransformerException ( e );
154 }
155
156 }
157
158 /**
159 * Execute the extension function.
160 */
171 // feature is set then invocation of extension functions need to
172 // throw XPathFunctionException
173 if ( extensionInvocationDisabled ) {
174 String fmsg = XSLMessages.createXPATHMessage(
175 XPATHErrorResources.ER_EXTENSION_FUNCTION_CANNOT_BE_INVOKED,
176 new Object[] { myQName.toString() } );
177 throw new XPathFunctionException ( fmsg );
178 }
179
180 XPathFunction xpathFunction =
181 resolver.resolveFunction( myQName, arity );
182
183 List<Object> argList = new ArrayList<>( arity);
184 for ( int i=0; i<arity; i++ ) {
185 XObject argument = argVec.get( i );
186 // XNodeSet object() returns NodeVector and not NodeList
187 // Explicitly getting NodeList by using nodelist()
188 if ( argument instanceof XNodeSet ) {
189 argList.add ( i, ((XNodeSet)argument).nodelist() );
190 } else if ( argument instanceof XObject ) {
191 Object passedArgument = argument.object();
192 argList.add ( i, passedArgument );
193 } else {
194 argList.add ( i, argument );
195 }
196 }
197
198 return ( xpathFunction.evaluate ( argList ));
199
200 } catch ( XPathFunctionException xfe ) {
201 // If we get XPathFunctionException then we want to terminate
202 // further execution by throwing WrappedRuntimeException
203 throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException ( xfe );
204 } catch ( Exception e ) {
205 throw new javax.xml.transform.TransformerException ( e );
206 }
207 }
208
209 }
|