xsl-list
[Top] [All Lists]

Re: [xsl] namespace problem

2014-09-08 02:56:35
On 09/05/14 17:24, Wolfgang Laun wolfgang(_dot_)laun(_at_)gmail(_dot_)com 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";
xmlns="http://www.w3.org/1999/xhtml";
                        xmlns:xs="http://www.w3.org/2001/XMLSchema";
                        exclude-result-prefixes="xs xsl">

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

  <xsl:template match="/">
    <document>
      <xsl:apply-templates/>
    </document>
  </xsl:template>

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

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

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

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

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


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>