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 2022/09/26 12:50:21 UTC
[xalan-java] branch xalan-j_2_7_1_maint updated: xalanj commit : minor improvements to error handling, during xslt transformation, with xalanj interpretive processor
This is an automated email from the ASF dual-hosted git repository.
mukulg pushed a commit to branch xalan-j_2_7_1_maint
in repository https://gitbox.apache.org/repos/asf/xalan-java.git
The following commit(s) were added to refs/heads/xalan-j_2_7_1_maint by this push:
new ca190b61 xalanj commit : minor improvements to error handling, during xslt transformation, with xalanj interpretive processor
ca190b61 is described below
commit ca190b61c3add0f9c0f8779adf93ea0aa35c3c9c
Author: Mukul Gandhi <ga...@gmail.com>
AuthorDate: Mon Sep 26 18:20:03 2022 +0530
xalanj commit : minor improvements to error handling, during xslt
transformation, with xalanj interpretive processor
---
src/org/apache/xalan/xslt/Process.java | 4 +++-
.../xslt/util/XslTransformErrorLocatorHelper.java | 27 ++++++++++++++++++++++
src/org/apache/xml/utils/DefaultErrorHandler.java | 10 ++++++--
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/src/org/apache/xalan/xslt/Process.java b/src/org/apache/xalan/xslt/Process.java
index a9648409..654c0587 100644
--- a/src/org/apache/xalan/xslt/Process.java
+++ b/src/org/apache/xalan/xslt/Process.java
@@ -56,8 +56,9 @@ import org.apache.xalan.res.XSLTErrorResources;
import org.apache.xalan.trace.PrintTraceListener;
import org.apache.xalan.trace.TraceManager;
import org.apache.xalan.transformer.XalanProperties;
+import org.apache.xalan.xslt.util.XslTransformErrorLocatorHelper;
import org.apache.xml.utils.DefaultErrorHandler;
-
+import org.apache.xml.utils.SystemIDResolver;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -749,6 +750,7 @@ public class Process
else
{
// System.out.println("Calling newTemplates: "+xslFileName);
+ XslTransformErrorLocatorHelper.systemId = SystemIDResolver.getAbsoluteURI(xslFileName);
stylesheet = tfactory.newTemplates(new StreamSource(xslFileName));
// System.out.println("Done calling newTemplates: "+xslFileName);
}
diff --git a/src/org/apache/xalan/xslt/util/XslTransformErrorLocatorHelper.java b/src/org/apache/xalan/xslt/util/XslTransformErrorLocatorHelper.java
new file mode 100644
index 00000000..a9db67f1
--- /dev/null
+++ b/src/org/apache/xalan/xslt/util/XslTransformErrorLocatorHelper.java
@@ -0,0 +1,27 @@
+/*
+ * 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.xslt.util;
+
+/**
+ * @version $Id: $
+ */
+public class XslTransformErrorLocatorHelper {
+
+ public static String systemId;
+
+}
diff --git a/src/org/apache/xml/utils/DefaultErrorHandler.java b/src/org/apache/xml/utils/DefaultErrorHandler.java
index 819f8e17..dc37ede9 100644
--- a/src/org/apache/xml/utils/DefaultErrorHandler.java
+++ b/src/org/apache/xml/utils/DefaultErrorHandler.java
@@ -27,6 +27,7 @@ import javax.xml.transform.ErrorListener;
import javax.xml.transform.SourceLocator;
import javax.xml.transform.TransformerException;
+import org.apache.xalan.xslt.util.XslTransformErrorLocatorHelper;
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
@@ -323,6 +324,7 @@ public class DefaultErrorHandler implements ErrorHandler, ErrorListener
Throwable cause = exception;
// Try to find the locator closest to the cause.
+ String xslSystemId = null;
do
{
if(cause instanceof SAXParseException)
@@ -332,8 +334,12 @@ public class DefaultErrorHandler implements ErrorHandler, ErrorListener
else if (cause instanceof TransformerException)
{
SourceLocator causeLocator = ((TransformerException)cause).getLocator();
- if(null != causeLocator)
+ if(null != causeLocator) {
+ if (causeLocator.getSystemId() == null) {
+ xslSystemId = XslTransformErrorLocatorHelper.systemId;
+ }
locator = causeLocator;
+ }
}
if(cause instanceof TransformerException)
cause = ((TransformerException)cause).getCause();
@@ -352,7 +358,7 @@ public class DefaultErrorHandler implements ErrorHandler, ErrorListener
String id = (null != locator.getPublicId() )
? locator.getPublicId()
: (null != locator.getSystemId())
- ? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
+ ? locator.getSystemId() : (null != xslSystemId) ? xslSystemId : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown";
pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber()
+ "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org