You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Mark Harburg <mh...@rome.com> on 2001/12/04 01:20:34 UTC

How to match namespaces in template?

I'm trying to match an element in an XML that has a namespace, but with no luck.  Here's what I tried:

-------- source xml --------
<?xml version="1.0"?>
<Workbook xmlns="aaa:bbb">
	hi
</Workbook>

--------- my xsl -----------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
      xmlns:aaa="http://www.test.org"
      xmlns:aaa:bbb="http://www.test.org">
   <xsl:template match="aaa:bbb:Workbook">
      <ws>
         <xsl:apply-templates/>
      </ws>
   </xsl:template>
</xsl:stylesheet>

-------------------------------

I can't seem to find an answer to this in any documentation.

Thanks.
-- 

_______________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


1 cent a minute calls anywhere in the U.S.!

http://www.getpennytalk.com/cgi-bin/adforward.cgi?p_key=RG9853KJ&url=http://www.getpennytalk.com



Re: How to match namespaces in template?

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
"Mark Harburg" <mh...@rome.com> writes:

> I'm trying to match an element in an XML that has a namespace, but with no luck.  Here's what I tried:
> 
> -------- source xml --------
> <?xml version="1.0"?>
> <Workbook xmlns="aaa:bbb">
> 	hi
> </Workbook>

Your example isn't that great...

There are a number of things broken here.

It is generally a bad idea to have the above XML with a colon.  I think it may
be invalid.  Or at least a bad idea.

Try 

<?xml version="1.0"?>
<Workbook xmlns="urn:aaa">
	hi
</Workbook>


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns="urn:aaa">

   <xsl:template match="Workbook">

      <ws>
          <xsl:apply-templates/>
       </ws>

   </xsl:template>

</xsl:stylesheet>
 

btw... you will also need to declare the xsl namespace.

Kevin

-- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

I'm intercontinental when I eat french toast...
    - Beck