xsl-list
[Top] [All Lists]

Re: how to remove xmlns attributes in html out put via copy-of

2004-12-10 09:14:49
whow guys! thanks a lot!

just for the archives - my test results:

Bruce, adding a default namespace to the xslt did not change anything,
unfortunately.

Geerts supposed solution left me with an attributeless anchor ... <a>bla</a>

Michaels supposed solution implemented like this
    <xsl:template match="*" mode="copy-sans-namespace">
        <xsl:element name="{local-name()}" namespace="">
            <xsl:copy-of select="@*" />
            <xsl:apply-templates mode="copy-sans-namespace" />
        </xsl:element>
    </xsl:template>
    <xsl:template match="entry:Para">
        <p>
            <xsl:apply-templates select="node()" />
        </p>
    </xsl:template>
actually removed the anchor. I am sure I did something wrong...

but António's link showed me a working solution:
    <xsl:template match="*">
        <!-- remove element prefix (if any) -->
        <xsl:element name="{local-name()}">
            <!-- process attributes -->
            <xsl:for-each select="@*">
                <!-- remove attribute prefix (if any) -->
                <xsl:attribute name="{local-name()}">
                    <xsl:value-of select="." />
                </xsl:attribute>
            </xsl:for-each>
            <xsl:apply-templates />
        </xsl:element>
    </xsl:template>
    <xsl:template match="entry:Para">
        <p>
            <xsl:apply-templates select="node()" />
        </p>
    </xsl:template>

works perfectly! Obrigado, Antonio, pela ajuda!

Another thanks for all of you

--
Jan


On Fri, 10 Dec 2004 15:40:43 +0000, António Mota <xptm(_at_)sapo(_dot_)pt> 
wrote:
Curiously, i just run Google on that, and i come across with this page:

http://wiki.apache.org/cocoon/RemoveNamespaces

The "Solutions, which do NOT work:" part save me a lot of time, and the
"Solutions, which WORK:" has various methods, starting by quoting Kay's XSLT
Programmer's Reference, so it should be a good resource...



Quoting Jan Limpens <jan(_dot_)limpens(_at_)gmail(_dot_)com>:

hi,

in my xml I have xhtml markup such as this:

<Document xmlns="http://limpens.com/entry";>
<Para>The solution came in the form of <a
href="http://authors.aspalliance.com/PaulWilson/Articles/?id=14";>Wilson's
Master pages</a>.</Para>
</Document>

my xslt tries to convert this to valid xml
      <xsl:template match="entry:Para">
              <p>
                      <xsl:copy-of select="node()" />
              </p>
      </xsl:template>

but produces xmlns attributes in the xhtml tags, such as...
<p>The solution came in the form of <a
href="http://authors.aspalliance.com/PaulWilson/Articles/?id=14";
xmlns="http://limpens.com/entry";>Wilson's Master pages</a>.</p>

wheather this is correct behaviour or not, I don't like the added
namespace in the anchor element too much, because it breaks my
otherwise valid xhtml.

I am using the .net (version 1.0) processor.
I tried to look it up in the archives and the faq, but didn't find
anything useful (whereas I am quite positive my question has already
been answered numeous times), so I hope nobody minds.

Thanks in advance!
--
Jan
http://www.limpens.com

Otakoo Saloon Cartoon - newest episode at http://limpens.com/oscredirect

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




O SAPO já está livre de vírus com a Panda Software, fique você também!
Clique em: http://antivirus.sapo.pt



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




-- 
Jan
http://www.limpens.com

Otakoo Saloon Cartoon - newest episode at http://limpens.com/oscredirect

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--