Subject: Re: [xsl] How to remove outer tag if present in XSLT From: "Matt Van Voorhies mvanvoorhies@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 17 Mar 2023 19:43:38 -0000 |
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).. So a <div> ... ... </div> Would not unwrap, since it's a "<div>" and not a "<p>" Thanks, Matt V. > ________________________________ From: Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Friday, March 17, 2023 1:01 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: [xsl] How to remove outer tag if present in XSLT Hi Matt, What are the precise conditions in which you want to ungroup the <p>? Is it when all of the following are true: * The element is a <p> element. * The <p> element is the only child of its parent (it stands alone). * The <p> element contains one or more child <p> elements. * The <p> element contains no non-<p> elements. * Chris From: Matt Van Voorhies mvanvoorhies@xxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Friday, March 17, 2023 12:56 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] How to remove outer tag if present in XSLT Hi folks, I have a hopefully simple question that I was unable to find a good answer for. Im 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 containing paragraph but only if its a single containing paragraph tag. Parsing using .NET Saxon 10.6 for transform. So for example, if I have the following XML structure <arbitrary-outer-tag-thats-valid> <p>Some content, probably a bunch of internal tags like H1, H2, LI, DIV, etc. </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. </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 <arbitrary-outer-tag-thats-valid> <p> <p>Some content, probably a bunch of internal tags like H1, H2, LI, DIV, etc. </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. </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@hotmail. com> XSL-List info and archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__ ;!!A4F2R9G_pg!f_qbvL1lxWOiZkRI0MumM1kH5KnOex4dlaYXYl62f4FzOdI62eejmsROCcOtdPJ gF-tbZjHczucMh-Dl7QrZrXNxWEcJ2NuFhCn7c_DukKs7FRSJCoPy$> EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu b/xsl-list/3380743__;!!A4F2R9G_pg!f_qbvL1lxWOiZkRI0MumM1kH5KnOex4dlaYXYl62f4F zOdI62eejmsROCcOtdPJgF-tbZjHczucMh-Dl7QrZrXNxWEcJ2NuFhCn7c_DukKs7FTtFsvdm$> (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<>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to remove outer tag i, Chris Papademetrious | Thread | Re: [xsl] How to remove outer tag i, Liam R. E. Quin liam |
Re: [xsl] How to remove outer tag i, Dimitre Novatchev dn | Date | Re: [xsl] How to remove outer tag i, Matt Van Voorhies mv |
Month |