Subject: Re: [xsl] How to remove outer tag if present in XSLT From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 17 Mar 2023 17:00:42 -0000 |
Am 3/17/2023 um 5:55 PM schrieb Matt Van Voorhies mvanvoorhies@xxxxxxxxxxx: > > 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. > > Perhaps B <xsl:template match="*/p[not(text()[normalize-space()]) and * and every every $c in * satisfies $c instance of element(p)]"> B B B B <xsl:apply-templates/> B </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to remove outer tag if pr, Matt Van Voorhies mv | Thread | Re: [xsl] How to remove outer tag i, Chris Papademetrious |
[xsl] How to remove outer tag if pr, Matt Van Voorhies mv | Date | Re: [xsl] How to remove outer tag i, Chris Papademetrious |
Month |