You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mu...@apache.org on 2025/02/23 17:17:14 UTC
(xalan-java) branch xalan-j_xslt3.0_mvn updated: committing implementation of xpath 3.1 function fn:doc-available and few related working test cases, and few improvements to implementation of fn:doc function
This is an automated email from the ASF dual-hosted git repository.
mukulg pushed a commit to branch xalan-j_xslt3.0_mvn
in repository https://gitbox.apache.org/repos/asf/xalan-java.git
The following commit(s) were added to refs/heads/xalan-j_xslt3.0_mvn by this push:
new e1afa62e0 committing implementation of xpath 3.1 function fn:doc-available and few related working test cases, and few improvements to implementation of fn:doc function
e1afa62e0 is described below
commit e1afa62e0b700c3bf96e63c649c8820f6168e122
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Sun Feb 23 22:47:02 2025 +0530
committing implementation of xpath 3.1 function fn:doc-available and few related working test cases, and few improvements to implementation of fn:doc function
---
.../org/apache/xpath/compiler/FunctionTable.java | 20 +++-
.../java/org/apache/xpath/compiler/Keywords.java | 3 +
.../java/org/apache/xpath/functions/FuncDoc.java | 72 ++++++++-----
.../apache/xpath/functions/FuncDocAvailable.java | 117 ++++++++++++++++++++
.../org/apache/xpath/functions/FuncParseXml.java | 16 +--
.../apache/xalan/tests/main/Xsl3TestSuite2.java | 4 +-
.../xalan/tests/xpath3/FnDocAvailableTests.java | 120 +++++++++++++++++++++
src/test/resources/fn_doc_available/gold/test1.out | 1 +
src/test/resources/fn_doc_available/gold/test2.out | 1 +
src/test/resources/fn_doc_available/gold/test3.out | 1 +
src/test/resources/fn_doc_available/gold/test4.out | 4 +
src/test/resources/fn_doc_available/gold/test5.out | 7 ++
src/test/resources/fn_doc_available/gold/test6.out | 1 +
src/test/resources/fn_doc_available/gold/test7.out | 5 +
src/test/resources/fn_doc_available/test1.xsl | 36 +++++++
src/test/resources/fn_doc_available/test2.xsl | 36 +++++++
src/test/resources/fn_doc_available/test3.xsl | 36 +++++++
src/test/resources/fn_doc_available/test4.xsl | 42 ++++++++
src/test/resources/fn_doc_available/test5.xml | 5 +
src/test/resources/fn_doc_available/test5.xsl | 44 ++++++++
src/test/resources/fn_doc_available/test6.xsl | 44 ++++++++
src/test/resources/fn_doc_available/test7.xsl | 44 ++++++++
22 files changed, 625 insertions(+), 34 deletions(-)
diff --git a/src/main/java/org/apache/xpath/compiler/FunctionTable.java b/src/main/java/org/apache/xpath/compiler/FunctionTable.java
index 7e7d2fe2a..d9865f8c2 100644
--- a/src/main/java/org/apache/xpath/compiler/FunctionTable.java
+++ b/src/main/java/org/apache/xpath/compiler/FunctionTable.java
@@ -26,6 +26,7 @@ import java.util.List;
import javax.xml.transform.TransformerException;
+import org.apache.xpath.functions.FuncDoc;
import org.apache.xpath.functions.Function;
/**
@@ -525,6 +526,9 @@ public class FunctionTable
/** The 'array:flatten()' id. */
public static final int FUNC_ARRAY_FLATTEN = 167;
+
+ /** The 'doc-available()' id. */
+ public static final int FUNC_DOC_AVAILABLE = 168;
// Proprietary
@@ -618,7 +622,7 @@ public class FunctionTable
* Number of built in functions. Be sure to update this as
* built-in functions are added.
*/
- private static final int NUM_BUILT_IN_FUNCS = 168;
+ private static final int NUM_BUILT_IN_FUNCS = 169;
/**
* Number of built-in functions that may be added.
@@ -898,6 +902,8 @@ public class FunctionTable
m_functions[FUNC_JSON_TO_XML] = org.apache.xpath.functions.json.FuncJsonToXml.class;
m_functions[FUNC_XML_TO_JSON] = org.apache.xpath.functions.json.FuncXmlToJson.class;
+ m_functions[FUNC_DOC_AVAILABLE] = org.apache.xpath.functions.FuncDocAvailable.class;
+
}
static{
@@ -1115,6 +1121,8 @@ public class FunctionTable
m_functionId.put(Keywords.FUNC_DOC,
new Integer(FunctionTable.FUNC_DOC));
+ m_functionId.put(Keywords.FUNC_DOC_AVAILABLE,
+ new Integer(FunctionTable.FUNC_DOC_AVAILABLE));
m_functionId.put(Keywords.FUNC_NODE_NAME,
new Integer(FunctionTable.FUNC_NODE_NAME));
@@ -1277,8 +1285,14 @@ public class FunctionTable
throws javax.xml.transform.TransformerException
{
try{
- if (which < NUM_BUILT_IN_FUNCS)
- return (Function) m_functions[which].newInstance();
+ if (which < NUM_BUILT_IN_FUNCS) {
+ if (which == FunctionTable.FUNC_DOC) {
+ return new FuncDoc();
+ }
+ else {
+ return (Function) m_functions[which].newInstance();
+ }
+ }
else
return (Function) m_functions_customer[
which-NUM_BUILT_IN_FUNCS].newInstance();
diff --git a/src/main/java/org/apache/xpath/compiler/Keywords.java b/src/main/java/org/apache/xpath/compiler/Keywords.java
index efb958a09..ad6dab0e7 100644
--- a/src/main/java/org/apache/xpath/compiler/Keywords.java
+++ b/src/main/java/org/apache/xpath/compiler/Keywords.java
@@ -688,6 +688,9 @@ public class Keywords
/** apply function string. */
public static final String FUNC_APPLY = "apply";
+ /** doc-available function string. */
+ public static final String FUNC_DOC_AVAILABLE = "doc-available";
+
// Proprietary, built in functions
/** current function string (Proprietary). */
diff --git a/src/main/java/org/apache/xpath/functions/FuncDoc.java b/src/main/java/org/apache/xpath/functions/FuncDoc.java
index 9d8dc95de..ca3a252b7 100644
--- a/src/main/java/org/apache/xpath/functions/FuncDoc.java
+++ b/src/main/java/org/apache/xpath/functions/FuncDoc.java
@@ -28,6 +28,7 @@ import org.apache.xalan.xslt.util.XslTransformEvaluationHelper;
import org.apache.xpath.ExpressionNode;
import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XObject;
+import org.xml.sax.ErrorHandler;
/**
* Implementation of the doc() function.
@@ -39,6 +40,22 @@ import org.apache.xpath.objects.XObject;
public class FuncDoc extends FunctionOneArg {
private static final long serialVersionUID = -7132184569695971726L;
+
+ private static ErrorHandler m_errorHandler = null;
+
+ /**
+ * Default constructor.
+ */
+ public FuncDoc() {
+ // NO OP
+ }
+
+ /**
+ * Class constructor.
+ */
+ public FuncDoc(ErrorHandler errorHandler) {
+ m_errorHandler = errorHandler;
+ }
/**
* Execute the function. The function must return a valid object.
@@ -60,31 +77,38 @@ public class FuncDoc extends FunctionOneArg {
// If the first argument is a relative uri reference, then
// resolve that relative uri with base uri of the stylesheet
+
URL resolvedArg0Url = null;
try {
- URI arg0Uri = new URI(hrefStrVal);
- String stylesheetSystemId = null;
- if (srcLocator != null) {
- stylesheetSystemId = srcLocator.getSystemId();
- }
- else {
- ExpressionNode expressionNode = getExpressionOwner();
- stylesheetSystemId = expressionNode.getSystemId();
- }
-
- if (!arg0Uri.isAbsolute() && (stylesheetSystemId != null)) {
- URI resolvedUriArg = (new URI(stylesheetSystemId)).resolve(hrefStrVal);
- resolvedArg0Url = resolvedUriArg.toURL();
- }
-
- if (resolvedArg0Url == null) {
- resolvedArg0Url = new URL(hrefStrVal);
- }
-
- String urlStrContents = XslTransformEvaluationHelper.getStringContentFromUrl(resolvedArg0Url);
-
- result = FuncParseXml.getNodeSetFromStr(urlStrContents, xctxt);
+ URI arg0Uri = new URI(hrefStrVal);
+
+ if (arg0Uri.isAbsolute()) {
+ resolvedArg0Url = new URL(hrefStrVal);
+ }
+ else {
+ String stylesheetSystemId = null;
+
+ if (srcLocator != null) {
+ stylesheetSystemId = srcLocator.getSystemId();
+ }
+ else {
+ ExpressionNode expressionNode = getExpressionOwner();
+ stylesheetSystemId = expressionNode.getSystemId();
+ }
+
+ if (stylesheetSystemId != null) {
+ URI resolvedUriArg = (new URI(stylesheetSystemId)).resolve(hrefStrVal);
+ resolvedArg0Url = resolvedUriArg.toURL();
+ }
+ else {
+ resolvedArg0Url = new URL(hrefStrVal);
+ }
+ }
+
+ String urlResourceStrContents = XslTransformEvaluationHelper.getStringContentFromUrl(resolvedArg0Url);
+
+ result = FuncParseXml.getNodeSetFromStr(urlResourceStrContents, xctxt, m_errorHandler);
}
catch (URISyntaxException ex) {
throw new javax.xml.transform.TransformerException("FODC0005 : The uri '" + hrefStrVal + "' is not a valid absolute uri, "
@@ -99,11 +123,11 @@ public class FuncDoc extends FunctionOneArg {
+ "retrieved.", srcLocator);
}
catch (javax.xml.transform.TransformerException ex) {
- throw new javax.xml.transform.TransformerException("FODC0002 : The data from uri '" + hrefStrVal + "' cannot be successfully "
+ throw new javax.xml.transform.TransformerException("FODC0002 : The data from uri '" + hrefStrVal + "' cannot be "
+ "parsed as an XML document.", srcLocator);
}
catch (Exception ex) {
- throw new javax.xml.transform.TransformerException("FODC0002 : The data from uri '" + hrefStrVal + "' cannot be successfully "
+ throw new javax.xml.transform.TransformerException("FODC0002 : The data from uri '" + hrefStrVal + "' cannot be "
+ "parsed as an XML document.", srcLocator);
}
diff --git a/src/main/java/org/apache/xpath/functions/FuncDocAvailable.java b/src/main/java/org/apache/xpath/functions/FuncDocAvailable.java
new file mode 100644
index 000000000..a30b611a5
--- /dev/null
+++ b/src/main/java/org/apache/xpath/functions/FuncDocAvailable.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xpath.functions;
+
+import org.apache.xpath.XPathContext;
+import org.apache.xpath.objects.ResultSequence;
+import org.apache.xpath.objects.XNodeSet;
+import org.apache.xpath.objects.XObject;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import xml.xpath31.processor.types.XSBoolean;
+
+/**
+ * Implementation of the doc-available() function.
+ *
+ * @author Mukul Gandhi <mu...@apache.org>
+ *
+ * @xsl.usage advanced
+ */
+public class FuncDocAvailable extends FunctionOneArg {
+
+ private static final long serialVersionUID = -737728533828222724L;
+
+ /**
+ * Execute the function. The function must return a valid object.
+ *
+ * @param xctxt The current execution context.
+ * @return A valid XObject.
+ *
+ * @throws javax.xml.transform.TransformerException
+ */
+ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
+
+ XObject result = null;
+
+ if ((m_arg0 == null) || ((m_arg0 instanceof ResultSequence) && (((ResultSequence)m_arg0).size() == 0))) {
+ // if function argument is an empty sequence, this function returns false
+ result = new XSBoolean(false);
+ }
+ else {
+ FuncDocErrorHandler funcDocErrorHandler = new FuncDocErrorHandler();
+
+ FuncDoc funcDoc = new FuncDoc(funcDocErrorHandler);
+ funcDoc.m_arg0 = this.m_arg0;
+
+ try {
+ XObject funcDocResult = funcDoc.execute(xctxt);
+ if (funcDocResult instanceof XNodeSet) {
+ result = new XSBoolean(true);
+ }
+ else {
+ result = new XSBoolean(false);
+ }
+ }
+ catch (javax.xml.transform.TransformerException ex) {
+ // if FuncDocErrorHandler object has isErrorOccured == true,
+ // we don't need to do anything specific about that. during that
+ // situation, code evaluation control comes here.
+ result = new XSBoolean(false);
+ }
+
+ if (result == null) {
+ result = new XSBoolean(false);
+ }
+ }
+
+
+ return result;
+ }
+
+ /**
+ * An org.xml.sax.ErrorHandler interface implementation. We bind an
+ * object of this class with javax.xml.parsers.DocumentBuilder later
+ * during processing of function fn:doc-available.
+ */
+ class FuncDocErrorHandler implements ErrorHandler {
+
+ private boolean isErrorOccured = false;
+
+ @Override
+ public void error(SAXParseException spe) throws SAXException {
+ isErrorOccured = true;
+ }
+
+ @Override
+ public void fatalError(SAXParseException spe) throws SAXException {
+ isErrorOccured = true;
+ }
+
+ @Override
+ public void warning(SAXParseException spe) throws SAXException {
+ // NO OP
+ }
+
+ public boolean getErrorStatus() {
+ return isErrorOccured;
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/apache/xpath/functions/FuncParseXml.java b/src/main/java/org/apache/xpath/functions/FuncParseXml.java
index 90d11d73b..a859cce9d 100644
--- a/src/main/java/org/apache/xpath/functions/FuncParseXml.java
+++ b/src/main/java/org/apache/xpath/functions/FuncParseXml.java
@@ -31,6 +31,7 @@ import org.apache.xpath.XPathContext;
import org.apache.xpath.objects.XNodeSet;
import org.apache.xpath.objects.XObject;
import org.w3c.dom.Document;
+import org.xml.sax.ErrorHandler;
/**
* Implementation of the parse-xml() function.
@@ -62,7 +63,7 @@ public class FuncParseXml extends FunctionOneArg {
String argStrVal = XslTransformEvaluationHelper.getStrVal(xObject0);
try {
- result = getNodeSetFromStr(argStrVal, xctxt);
+ result = getNodeSetFromStr(argStrVal, xctxt, null);
}
catch (Exception ex) {
throw new javax.xml.transform.TransformerException("FODC0002 : The string value supplied as an "
@@ -76,21 +77,24 @@ public class FuncParseXml extends FunctionOneArg {
/**
* Get an xdm nodeset corresponding to an XML string value.
*/
- public static XNodeSet getNodeSetFromStr(String strVal, XPathContext xctxt) throws Exception {
+ public static XNodeSet getNodeSetFromStr(String strVal, XPathContext xctxt, ErrorHandler errorHandler) throws Exception {
XNodeSet nodeSet = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- // Enable the XML namespace processing, on an XML parse
- // of the string value.
+ // Enable XML namespace processing, for XML parse of the string value
dbf.setNamespaceAware(true);
DocumentBuilder dBuilder = dbf.newDocumentBuilder();
+
+ if (errorHandler != null) {
+ dBuilder.setErrorHandler(errorHandler);
+ }
InputStream inpStream = new ByteArrayInputStream(strVal.getBytes(StandardCharsets.UTF_8));
- Document xmlDocument = dBuilder.parse(inpStream);
+ Document document = dBuilder.parse(inpStream);
- DTM dtm = xctxt.getDTM(new DOMSource(xmlDocument), true, null, false, false);
+ DTM dtm = xctxt.getDTM(new DOMSource(document), true, null, false, false);
int documentNodeHandleVal = dtm.getDocument();
nodeSet = new XNodeSet(documentNodeHandleVal, xctxt.getDTMManager());
diff --git a/src/test/java/org/apache/xalan/tests/main/Xsl3TestSuite2.java b/src/test/java/org/apache/xalan/tests/main/Xsl3TestSuite2.java
index 6135ba28d..334f71ff0 100644
--- a/src/test/java/org/apache/xalan/tests/main/Xsl3TestSuite2.java
+++ b/src/test/java/org/apache/xalan/tests/main/Xsl3TestSuite2.java
@@ -22,6 +22,7 @@ import org.apache.xalan.tests.xpath3.FnCodepointsToStringTests;
import org.apache.xalan.tests.xpath3.FnCompareTests;
import org.apache.xalan.tests.xpath3.FnContainsTokenTests;
import org.apache.xalan.tests.xpath3.FnDistinctValuesTests;
+import org.apache.xalan.tests.xpath3.FnDocAvailableTests;
import org.apache.xalan.tests.xpath3.FnFilterTests;
import org.apache.xalan.tests.xpath3.FnFoldLeftTests;
import org.apache.xalan.tests.xpath3.FnFoldRightTests;
@@ -98,7 +99,8 @@ import org.junit.runners.Suite.SuiteClasses;
XPathSequenceFunctionTests.class, FnParseXmlTests.class, FnParseXmlFragmentTests.class,
XslTemplateTests.class, FnAvgTests.class, FnMaxTests.class, FnMinTests.class, FnContainsTokenTests.class,
XslVariableAttributeAsTests.class, XPathInstanceOfExprTests.class, XslTemplateAttributeAsTests.class,
- FnRoundTests.class, XslSequenceInstTests.class, XPathNodeSequenceCombinationTests.class })
+ FnRoundTests.class, XslSequenceInstTests.class, XPathNodeSequenceCombinationTests.class,
+ FnDocAvailableTests.class })
public class Xsl3TestSuite2 {
}
diff --git a/src/test/java/org/apache/xalan/tests/xpath3/FnDocAvailableTests.java b/src/test/java/org/apache/xalan/tests/xpath3/FnDocAvailableTests.java
new file mode 100644
index 000000000..1f732b190
--- /dev/null
+++ b/src/test/java/org/apache/xalan/tests/xpath3/FnDocAvailableTests.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xalan.tests.xpath3;
+
+import org.apache.xalan.tests.util.XSLConstants;
+import org.apache.xalan.tests.util.XSLTransformTestsUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * XPath 3.1 function fn:doc-available test cases.
+ *
+ * @author Mukul Gandhi <mu...@apache.org>
+ *
+ * @xsl.usage advanced
+ */
+public class FnDocAvailableTests extends XSLTransformTestsUtil {
+
+ private static final String XSL_TRANSFORM_INPUT_DIRPATH = XSLConstants.XSL_TRANSFORM_INPUT_DIRPATH_PREFIX + "fn_doc_available/";
+
+ private static final String XSL_TRANSFORM_GOLD_DIRPATH = XSLConstants.XSL_TRANSFORM_GOLD_DIRPATH_PREFIX + "fn_doc_available/gold/";
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // no op
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ xmlDocumentBuilderFactory = null;
+ xmlDocumentBuilder = null;
+ xslTransformerFactory = null;
+ }
+
+ @Test
+ public void xslFnDocAvailableTest1() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test1.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test1.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDocAvailableTest2() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test2.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test2.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDocAvailableTest3() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test3.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test3.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test3.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDocAvailableTest4() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test4.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test4.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test4.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDocAvailableTest5() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test5.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test5.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test5.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDocAvailableTest6() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test6.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test6.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+ @Test
+ public void xslFnDocAvailableTest7() {
+ String xmlFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test7.xsl";
+ String xslFilePath = XSL_TRANSFORM_INPUT_DIRPATH + "test7.xsl";
+
+ String goldFilePath = XSL_TRANSFORM_GOLD_DIRPATH + "test7.out";
+
+ runXslTransformAndAssertOutput(xmlFilePath, xslFilePath, goldFilePath, null);
+ }
+
+}
diff --git a/src/test/resources/fn_doc_available/gold/test1.out b/src/test/resources/fn_doc_available/gold/test1.out
new file mode 100644
index 000000000..62d104166
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test1.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>true</result>
diff --git a/src/test/resources/fn_doc_available/gold/test2.out b/src/test/resources/fn_doc_available/gold/test2.out
new file mode 100644
index 000000000..a86d37f6a
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test2.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>false</result>
diff --git a/src/test/resources/fn_doc_available/gold/test3.out b/src/test/resources/fn_doc_available/gold/test3.out
new file mode 100644
index 000000000..a86d37f6a
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test3.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>false</result>
diff --git a/src/test/resources/fn_doc_available/gold/test4.out b/src/test/resources/fn_doc_available/gold/test4.out
new file mode 100644
index 000000000..d6d7e43a3
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test4.out
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <one>false</one>
+ <two>false</two>
+</result>
diff --git a/src/test/resources/fn_doc_available/gold/test5.out b/src/test/resources/fn_doc_available/gold/test5.out
new file mode 100644
index 000000000..f8280534d
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test5.out
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <doc>
+ <a/>
+ <b/>
+ <c/>
+</doc>
+</result>
diff --git a/src/test/resources/fn_doc_available/gold/test6.out b/src/test/resources/fn_doc_available/gold/test6.out
new file mode 100644
index 000000000..2efa0deff
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test6.out
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><result>The URL file_not_found.xml either doesnt refer to a physical document, or document exists at this URL but its not well-formed XML document.</result>
diff --git a/src/test/resources/fn_doc_available/gold/test7.out b/src/test/resources/fn_doc_available/gold/test7.out
new file mode 100644
index 000000000..8e3c163c4
--- /dev/null
+++ b/src/test/resources/fn_doc_available/gold/test7.out
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?><result>
+ <info>
+ <a1/>
+</info>
+</result>
diff --git a/src/test/resources/fn_doc_available/test1.xsl b/src/test/resources/fn_doc_available/test1.xsl
new file mode 100644
index 000000000..2b5c0e091
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test1.xsl
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:value-of select="doc-available('https://xalan.apache.org/xalan-j/xsl3/tests/data/test1_a.xml')"/>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test2.xsl b/src/test/resources/fn_doc_available/test2.xsl
new file mode 100644
index 000000000..e30f711c2
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test2.xsl
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:value-of select="doc-available('http://url_not_available')"/>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test3.xsl b/src/test/resources/fn_doc_available/test3.xsl
new file mode 100644
index 000000000..400ec5c96
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test3.xsl
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:value-of select="doc-available('https://xalan.apache.org/xalan-j/xsl3/tests/data/file1.json')"/>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test4.xsl b/src/test/resources/fn_doc_available/test4.xsl
new file mode 100644
index 000000000..b3a18e249
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test4.xsl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <one>
+ <xsl:value-of select="doc-available(())"/>
+ </one>
+ <two>
+ <xsl:variable name="seq1" select="()"/>
+ <xsl:value-of select="doc-available($seq1)"/>
+ </two>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test5.xml b/src/test/resources/fn_doc_available/test5.xml
new file mode 100644
index 000000000..e17f317c7
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test5.xml
@@ -0,0 +1,5 @@
+<doc>
+ <a/>
+ <b/>
+ <c/>
+</doc>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test5.xsl b/src/test/resources/fn_doc_available/test5.xsl
new file mode 100644
index 000000000..02ba30e95
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test5.xsl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:variable name="urlRef1" select="'test5.xml'"/>
+ <xsl:choose>
+ <xsl:when test="doc-available($urlRef1)">
+ <xsl:copy-of select="doc($urlRef1)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="'The URL ' || $urlRef1 || ' either doesnt refer to a physical document, or document exists at this URL but its not well-formed XML document.'"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test6.xsl b/src/test/resources/fn_doc_available/test6.xsl
new file mode 100644
index 000000000..2c891b8b7
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test6.xsl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:variable name="urlRef1" select="'file_not_found.xml'"/>
+ <xsl:choose>
+ <xsl:when test="doc-available($urlRef1)">
+ <xsl:copy-of select="doc($urlRef1)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="'The URL ' || $urlRef1 || ' either doesnt refer to a physical document, or document exists at this URL but its not well-formed XML document.'"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
diff --git a/src/test/resources/fn_doc_available/test7.xsl b/src/test/resources/fn_doc_available/test7.xsl
new file mode 100644
index 000000000..2082cadd3
--- /dev/null
+++ b/src/test/resources/fn_doc_available/test7.xsl
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="3.0">
+
+ <!-- Author: mukulg@apache.org -->
+
+ <!-- An XSL stylesheet test case for XPath 3.1 function
+ fn:doc-available. -->
+
+ <xsl:output method="xml" indent="yes"/>
+
+ <xsl:template match="/">
+ <result>
+ <xsl:variable name="urlRef1" select="'https://xalan.apache.org/xalan-j/xsl3/tests/data/test1_a.xml'"/>
+ <xsl:choose>
+ <xsl:when test="doc-available($urlRef1)">
+ <xsl:copy-of select="doc($urlRef1)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="'The URL ' || $urlRef1 || ' either doesnt refer to a physical document, or document exists at this URL but its not well-formed XML document.'"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </result>
+ </xsl:template>
+
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+</xsl:stylesheet>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org