Hi Schimon,
Due to my curiosity, I've tried writing an XSLT 3.0 stylesheet to
solve this issue, using David Carlisle's interpretation for well-formedness
of your XHTML document input.
I've used an XML document input (I used XML document rules to solve this
use case):
<atom:summary type="xhtml"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:div>
<xhtml:p>
We are happy to announce that
<xhtml:a href="gemini://syndikate.i2p">Syndikate</xhtml:a>
was publicized.
</xhtml:p>
</xhtml:div>
</atom:summary>
and provided that to an XSLT 3.0 stylesheet:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="atom xhtml"
version="3.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="atom:summary">
<xsl:apply-templates select="xhtml:div/xhtml:p"/>
</xsl:template>
<xsl:template match="xhtml:p">
<p xmlns="http://www.w3.org/1999/xhtml" class="summary" type="xhtml">
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}" namespace="
http://www.w3.org/1999/xhtml">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
This XSL transformation produces following result,
<?xml version="1.0" encoding="UTF-8"?>
<p xmlns="http://www.w3.org/1999/xhtml" class="summary" type="xhtml">
We are happy to announce that
<a href="gemini://syndikate.i2p">Syndikate</a>
was publicized.
</p>
Many thanks.
On Mon, Mar 9, 2026 at 12:59b/AM Schimon Jehudah sch@xxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Greetings.
>
> I am attempting to copy the XHTML content of element atom:summary
> without the prefix of "xhtml", by declaring the XML Namespace of "xhtml"
> at the element which contains it.
>
> Content
> -------
>
> <atom:summary type="xhtml">
> <xhtml:div>
> <xhtml:p>
> We are happy to announce that
> <xhtml:a href="gemini://syndikate.i2p">Syndikate</xhtml:a>
> was publicized.
> <xhtml:p>
> </xhtml:div>
> </atom:summary>
>
>
> XSLT
> ----
>
> <p xmlns="http://www.w3.org/1999/xhtml" class="summary" type="xhtml">
> <xsl:copy-of select="$summary/xhtml:*"/>
> </p>
>
>
> Result
> ------
>
> <p xmlns="http://www.w3.org/1999/xhtml" class="summary" type="xhtml">
> <xhtml:div>
> <xhtml:p>
> We are happy to announce that
> <xhtml:a href="gemini://syndikate.i2p">Syndikate</xhtml:a>
> was publicized.
> <xhtml:p>
> </xhtml:div>
> </p>
>
>
> Desired result
> --------------
>
> <p xmlns="http://www.w3.org/1999/xhtml" class="summary" type="xhtml">
> <div>
> <p>
> We are happy to announce that
> <a href="gemini://syndikate.i2p">Syndikate</a>
> was publicized.
> <p>
> </div>
> </p>
>
>
> Note
> ----
>
> Directive exclude-result-prefixes="xhtml" did not work for me, or I
> executed it wrongly.
>
> I would appreciate any help.
>
>
> Kind reagrds,
> Schimon
>
--
Regards,
Mukul Gandhi
|