You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by James Richardson <ja...@db.com> on 2002/10/11 17:38:40 UTC

Problem when input document contains attribute xmlns

I would much appreciate any help with the following problem. I am pretty new to XSL, so I may have screwed something up.

Using the following stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<!-- Default processing: output nothing -->

<xsl:template match="text()" >
</xsl:template>

<xsl:template match="jobId">
     <P><xsl:value-of select="."/></P>
     <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>


The following input document will not generate any output:

<jobsContainer><jobContainer><job xmlns="http://twister.db.com/com/db/twister/message/job">
<jobId>226</jobId><jobConfig><queueName>**Unused**</queueName>
<priorityCode>10</priorityCode></jobConfig>
<jobState><startTime>1034342919446</startTime>
<statusCode>1</statusCode></jobState></job></jobContainer>
</jobsContainer>

However, if you change the 'xmlns' in the input document to 'foo' it works. (Displays '226' )

The real stylesheet, input etc, that I'm using is far more complicated, but this demonstrates the issue.

Do I need to implement a URIResolver? Surely this is 'just text', and has not special meaning to the processor?

Thanks so much for any help/suggestions,

James


Re: Problem when input document contains attribute xmlns

Posted by Joseph Kesselman <ke...@us.ibm.com>.
XSLT does not support non-namespace-aware processing. If that's what you 
want, you need another tool. Sorry, but XML 1.0 without namespaces is 
pretty much deprecated at this point.

______________________________________
Joe Kesselman  / IBM Research

Re: Problem when input document contains attribute xmlns

Posted by James Richardson <ja...@db.com>.
Joseph Kesselman wrote:
> An attribute called xmlns declares the default namespace for that element 
> and its descendents. See the namespaces spec.
> 
> ______________________________________
> Joe Kesselman  / IBM Research

In reply to my own:
 >> In this particular context, its not a namespace, its just an attribute of some input XML that happens to be 'xmlns' (!?)

Indeed i already did, when I read your initial post.

I was just making a (perhaps less-than-helpful) observation. Cos I was hoping that I would be able to transform XML1.0, not only (XML1.0+Namespaces Recommendation).

I would rather no namespaces at all in the source xml, but castor adds what it will....

Thanks for your help, now it does indeed work!

Cheers

James





Re: Problem when input document contains attribute xmlns

Posted by Joseph Kesselman <ke...@us.ibm.com>.
An attribute called xmlns declares the default namespace for that element 
and its descendents. See the namespaces spec.

______________________________________
Joe Kesselman  / IBM Research

Re: Problem when input document contains attribute xmlns

Posted by James Richardson <ja...@db.com>.
Joseph Kesselman wrote:
> This is a FAQ.
> 
> XSLT is namespace-sensitive. If you specify a namespace in your source 
> document you _must_ use that namespace when your stylesheet attempts to 
> check the node's names, or the match will fail. XSLT 1.0 has no concept of 
> default namespace in select or match patterns, so within the stylesheet 
> you must declare a prefix for that namespace and use that prefix in your 
> patterns even though you don't have an explicit prefix in your source 
> document.
> 
> ______________________________________
> Joe Kesselman  / IBM Research

In this particular context, its not a namespace, its just an attribute of some input XML that happens to be 'xmlns' (!?)

Thanks a lot though for your suggestion, I will try it out now!

Best Regards,

James



Re: Problem when input document contains attribute xmlns

Posted by Joseph Kesselman <ke...@us.ibm.com>.
This is a FAQ.

XSLT is namespace-sensitive. If you specify a namespace in your source 
document you _must_ use that namespace when your stylesheet attempts to 
check the node's names, or the match will fail. XSLT 1.0 has no concept of 
default namespace in select or match patterns, so within the stylesheet 
you must declare a prefix for that namespace and use that prefix in your 
patterns even though you don't have an explicit prefix in your source 
document.

______________________________________
Joe Kesselman  / IBM Research