You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Giacomo Villoresi (JIRA)" <xa...@xml.apache.org> on 2005/07/05 13:00:24 UTC

[jira] Created: (XALANJ-2165) Stylesheet calling customized document() function namespace problem

Stylesheet calling customized document() function namespace problem
-------------------------------------------------------------------

         Key: XALANJ-2165
         URL: http://issues.apache.org/jira/browse/XALANJ-2165
     Project: XalanJ2
        Type: Bug
  Components: XSLTC  
    Versions: 2.6    
 Environment: Windows XP SP2
Java SDK 1.5.0
    Reporter: Giacomo Villoresi


Hi,
 I needed to customize the XSLT document() function to manage certain exceptions, so I wrote an utility class in Java with the loadDocument() static method.
Here is a part of the Stylesheet, that invokes the external method:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ic="http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsltutil="my.package.XSLTUtil" exclude-result-prefixes="ic xsltutil">
[...]
<xsl:variable name="doc" select="xsltutil:loadDocument($doc-url)"/>
[...]

and this is a snippet of the Java code:

import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class XSLTUtil {

[...]

public static Node loadDocument(String urlString) {
	try {
		URL url = new URL(urlString);
		InputStream is = url.openStream();
		Document doc = DocumentBuilderFactory.newInstance()
				.newDocumentBuilder().parse(is);
		return doc;
	} catch (Exception e) {
		getLog().error("Unable to load document: " + e.getMessage());
	}
	try {
		return DocumentBuilderFactory.newInstance().newDocumentBuilder()
				.newDocument();
	} catch (Exception ignored) {
	}
	return null;
}
}

the code works well when I try to load document without namespace, but in all the other cases (default namespace or qualified elements, using only namespaces also declared in the stylesheet, for instance the one with the "ic" prefix) the XSLT hangs with the following error:

'NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.'

while I notice that Xalan interpreter simply removes the namespace.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Re: [jira] Created: (XALANJ-2165) Stylesheet calling customized document() function namespace problem

Posted by Axel Weiß <aw...@informatik.hu-berlin.de>.
Giacomo Villoresi (JIRA) wrote:
> 'NAMESPACE_ERR: An attempt is made to create or change an object in a
> way which is incorrect with regard to namespaces.'
>
> while I notice that Xalan interpreter simply removes the namespace.

Hi Giacomo,

you need to set namespace and validation features to your factory, e.g.
	factory.setNamespaceAware(true);
	factory.setValidating(true);

Otherwise namespaces will just be ignored.

Cheers,
			Axel

-- 
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2165) Stylesheet calling customized document() function namespace problem

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2165?page=comments#action_12315669 ] 

Brian Minchau commented on XALANJ-2165:
---------------------------------------

This message was posted to xalan-dev by Axel, which I copy and paste here:

Giacomo Villoresi (JIRA) wrote:
> 'NAMESPACE_ERR: An attempt is made to create or change an object in a
> way which is incorrect with regard to namespaces.'
>
> while I notice that Xalan interpreter simply removes the namespace.

Hi Giacomo,

you need to set namespace and validation features to your factory, e.g.
	factory.setNamespaceAware(true);
	factory.setValidating(true);

Otherwise namespaces will just be ignored.

Cheers,
			Axel

-- 
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **


> Stylesheet calling customized document() function namespace problem
> -------------------------------------------------------------------
>
>          Key: XALANJ-2165
>          URL: http://issues.apache.org/jira/browse/XALANJ-2165
>      Project: XalanJ2
>         Type: Bug
>   Components: XSLTC
>     Versions: 2.6
>  Environment: Windows XP SP2
> Java SDK 1.5.0
>     Reporter: Giacomo Villoresi

>
> Hi,
>  I needed to customize the XSLT document() function to manage certain exceptions, so I wrote an utility class in Java with the loadDocument() static method.
> Here is a part of the Stylesheet, that invokes the external method:
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ic="http://www.unidata.ucar.edu/namespaces/thredds/InvCatalog/v1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsltutil="my.package.XSLTUtil" exclude-result-prefixes="ic xsltutil">
> [...]
> <xsl:variable name="doc" select="xsltutil:loadDocument($doc-url)"/>
> [...]
> and this is a snippet of the Java code:
> import javax.xml.parsers.DocumentBuilderFactory;
> import org.w3c.dom.Document;
> import org.w3c.dom.Node;
> public class XSLTUtil {
> [...]
> public static Node loadDocument(String urlString) {
> 	try {
> 		URL url = new URL(urlString);
> 		InputStream is = url.openStream();
> 		Document doc = DocumentBuilderFactory.newInstance()
> 				.newDocumentBuilder().parse(is);
> 		return doc;
> 	} catch (Exception e) {
> 		getLog().error("Unable to load document: " + e.getMessage());
> 	}
> 	try {
> 		return DocumentBuilderFactory.newInstance().newDocumentBuilder()
> 				.newDocument();
> 	} catch (Exception ignored) {
> 	}
> 	return null;
> }
> }
> the code works well when I try to load document without namespace, but in all the other cases (default namespace or qualified elements, using only namespaces also declared in the stylesheet, for instance the one with the "ic" prefix) the XSLT hangs with the following error:
> 'NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.'
> while I notice that Xalan interpreter simply removes the namespace.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org