1 person found this helpful
Style note: Please use >> Syntax Highlighting > XML in the web interface. It makes your code much more readable.
<xsl:template match="/myArticle/Content//p"> <xsl:element name="p"><xsl:apply-templates /></xsl:element> </xsl:template>
This template's XPath expresion has //p so it will match all <p/> nodes beneath at any level.
I think that is not what you want here, since it means it will match both the paragraph-within-paragraph and also its parent, so it prints them twice.
I think your whole structure isn't quite right here ... I try to avoid XSLT as much as possible, but my recollection is you really want templates with constraints like match="p" rather than the sort of explicit positions you have.
But it's also not normal to have nested <p> tags -- is that really the situation you have, or is it some other tag? I would say it is not a great way to structure your XML, and it may lead to, for instance, gross confusion on the part of the app that is reading the XML (such as InDesign).
So consider doing it another way?
Thanks for the tip. I didn't know there was syntax highlighting in the forums.
Yes, sometimes there may be embedded tags of nearly any type. HTML is not an exact science (unfortunatly) so I have to prepare my transform for certain things that may be thrown at it.
I believe I solved the issue. I changed
<xsl:template match="/"> <xsl:element name="body"><xsl:apply-templates select="/myArticle/Content//*" /></xsl:element> </xsl:template> </xsl:stylesheet>
<xsl:template match="/"> <xsl:element name="body"><xsl:apply-templates select="/myArticle/Content" /></xsl:element> </xsl:template> </xsl:stylesheet>
(got rid of the //* from the main template)
and it is working correctly.
Oh, yeah, that would do it! I picked on the wrong "//"!
But I suspect you could still write it a lot simpler...