bbbbbb<arbitrary-outer-tag>
bbbbbb<div>
bbbbbbbbbbbb<p>content<p>
bbbbbbbbbbbb<div>text</div
bbbbbbbbbbbb<b>more text</b>
bbbbbb</div>
bbbbbb<arbitrary-outer-tag>
bbbbbbWould remain unchanged?
bbbbbbThanks,
bbbbbbbbbbbbMatt V.
------------------------------------------------------------------------
*From:* Dimitre Novatchev dnovatchev@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
*Sent:* Friday, March 17, 2023 1:26 PM
*To:* xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
*Subject:* Re: How to remove outer tag if present in XSLT
A simple XSLT 1.0 solution (using even Saxon 6.5.3 is OK :) ):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform
<http://www.w3.org/1999/XSL/Transform>">
B <xsl:output omit-xml-declaration="yes" indent="yes"/>
B <xsl:strip-space elements="*"/>
B <xsl:template match="node()|@*">
B B <xsl:copy>
B B B <xsl:apply-templates select="node()|@*"/>
B B </xsl:copy>
B </xsl:template>
B <xsl:template
match="arbitrary-outer-tag-thats-valid/*[1][not(following-sibling::*)]">
B B B <xsl:apply-templates/>
B </xsl:template>
</xsl:stylesheet>
Thanks,
Dimitre
On Fri, Mar 17, 2023 at 9:55b/AM Matt Van Voorhies
mvanvoorhies@xxxxxxxxxxx <mailto:mvanvoorhies@xxxxxxxxxxx>
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx
<mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote:
__ __
Hi folks,__ __
__ __
I have a hopefully simple question that I was unable to find a good
answer for.Ibm trying to convert some code we have that manipulates
an XML structure (transforming to HTML output) and move it into the
XSLT transform.__ __
__ __
Problem:Given a specific XML tag, I need to remove the bcontaining
paragraphb but only if itbs a single containing paragraph
tag.Parsing using .NET Saxon 10.6 for transform.__ __
__ __
So for example, if I have the following XML structure b __ __
__ __
<arbitrary-outer-tag-thats-valid>
<p>Some content, probably a bunch of internal tags like H1, H2, LI,
DIV, etc.B </p>
<p>More content, again, may have more stuff in it like an
<p>Internal paragraph</p></p>
<p>stuff3</p>
</ arbitrary-outer-tag-thats-valid >__ __
__ __
Running through the transform would produce:__ __
__ __
<arbitrary-outer-tag-thats-valid>
<p>Some content, probably a bunch of internal tags like H1, H2, LI,
DIV, etc.B </p>
<p>More content, again, may have more stuff in it like an
<p>Internal paragraph</p></p>
<p>stuff3</p>
</ arbitrary-outer-tag-thats-valid >__ __
__ __
Since there is *not* an outer/containing paragraph tag.__ __
__ __
However, if the input was b __ __
__ __
<arbitrary-outer-tag-thats-valid>__ __
*<p>*
<p>Some content, probably a bunch of internal tags like H1, H2, LI,
DIV, etc.B </p>
<p>More content, again, may have more stuff in it like an
<p>Internal paragraph</p></p>
<p>stuff3</p>__ __
*</p>*
</ arbitrary-outer-tag-thats-valid >__ __
__ __
Running through the transform would produce:__ __
__ __
<arbitrary-outer-tag-thats-valid>
<p>Some content, probably a bunch of internal tags like H1, H2, LI,
DIV, etc.B </p>
<p>More content, again, may have more stuff in it like an
<p>Internal paragraph</p></p>
<p>stuff3</p>
</ arbitrary-outer-tag-thats-valid >__ __
__ __
Where the single, containing <p> tag was removed, but everything
inside of it was retained exactly as it was.__ __
__ __
Could someone help?__ __
__ __
Thanks,__ __
Matt Van Voorhies__ __
mvanvoorhies@xxxxxxxxxxx <mailto:mvanvoorhies@xxxxxxxxxxx>__ __
__ __
__ __
__ __
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe
<http://lists.mulberrytech.com/unsub/xsl-list/782854> (by email)
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3506713>
(by email)
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2554186>
(by email <>)