Domanda

I have a XML document which root node is sv:node and I am trying to define a template who match this root node.
When my root node has no prefix it usually works but in this case an exception is thrown.

<xsl:template name="/sv:node" />

I am using JAVA with the Apache XALAN XSLT processor which raises a RuntimeException

Caused by: java.lang.RuntimeException: Le préfixe doit se convertir en espace de noms : /sv
    at org.apache.xml.utils.QName.<init>(QName.java:450)
    at org.apache.xalan.processor.XSLTAttributeDef.processQNAME(XSLTAttributeDef.java:937)

I apologize about the localized message of the RuntimeException, basically it is complaining about the prefix with is not mapped to a namespace.

So the question is, how can I match this root node?

Edit : Here is my stylesheet tag Here is my stylesheet tag :

<xsl:stylesheet version="1.0" 
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:zip="http://apache.org/cocoon/zip-archive/1.0"
            xmlns:sv="http://www.jcp.org/jcr/sv/1.0">
È stato utile?

Soluzione

I suspect you really meant

<xsl:template match="/sv:node" />

(with match rather than name). Using <xsl:template name="..."> declares a named template which can be called by <xsl:call-template>, not a matching template for <xsl:apply-templates>, and the name of a named template must be a QName. The exception is telling you that it's trying to treat the three characters "forward-slash, s, v" as the prefix part of the QName and finding that this prefix is not mapped to a URI.

Altri suggerimenti

It was a silly mistake, I was using

<xsl:template name="/sv:node" />

instead of

<xsl:template match="/sv:node" />
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top