[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] namespace problem

Subject: Re: [xsl] namespace problem
From: "Ruud Grosmann r.grosmann@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 8 Sep 2014 07:56:24 -0000

On 09/05/14 17:24, Wolfgang Laun wolfgang.laun@xxxxxxxxx wrote:
Hi Ruud,

I'm not sure what you misunderstood, but here's the XSLT that does what you
want. I've added a couple of comments to indicate what goes on where.

hi Wolfgang,

thank you for your patience. Your reply was exactly what I needed to understand what is going on.
The solution in your mail is not what I was looking for, because it would have meant that I would have to insert the namespace in each starttag. The transform I am working with has a lot of starttags already so that would have been very laborious.

The other way around is in my case a lot more attractive, that is explicitly putting the contents of the variable in the no namespace. As you explained, because of the namespace on the root element of the transform, the variable ended up having that namespace too, and the match was doing a no namespace match.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xs xsl">

<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />

  <xsl:template match="/">

  <xsl:template match="p">
    <xsl:variable name='blip'>
      <xsl:apply-templates />

    <xsl:apply-templates select='$blip' mode='pass2' />

  <xsl:template match="Char">
    <!-- put explicitly in no namespace. -->
    <char xmlns=''><xsl:apply-templates /></char>

  <xsl:template match='char' mode='#all'>
    <c><xsl:apply-templates /></c>

I am still wondering what the solution should have been when I only wanted to change the match. So how could I have matched a char element in the http://www.w3.org/1999/xhtml namespace only?
I saw that doing a match on '*:char' made the transform work, but I didn't like the idea of that approach.

thanks anyhow, very glad with your help!
regards, Ruud

Current Thread