Re: [xsl] How to remove outer tag if present in XSLT

Subject: Re: [xsl] How to remove outer tag if present in XSLT
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 17 Mar 2023 22:29:41 -0000
On Fri, 2023-03-17 at 19:44 +0000, Matt Van Voorhies
mvanvoorhies@xxxxxxxxxxx wrote:
>
> B B B B B  Ungroup (remove) the outer <p> if it is the only element that
> is a child of the arbitrary outer node (and is a <p> node)..
>
> B B B B B  So a <div>
> B B B B B B B B B B B  ...
> B B B B B B B B B B B  ...
> B B B B B B B B B  </div>
> B B B B 
> B B B B B  Would not unwrap, since it's a "<div>" and not a "<p>"

<xsl:template match="p[p and count(../*) = 1]">
  <xsl:apply-templates/>
</xsl:template>

will unwrap every p element that contains p element and has no
siblings.

liam

--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

Current Thread