Tricky text node XPath address

luqian

New Member
I want to grab a specific text node in my XML right after a tag but I have to make my XPath very specific cause there happens to be alot of text nodes following 's throughout my source document. This case is very unique because it is followed by a text node followed by 2
and one children, signifying a definition list. The point of interest in my source document looks like this (it is malformed but that is what I'm dealing with):\[code\]<p> <a> WANT TO GRAB TEXT NODE HERE <br/> <br/> <i> WORD </i> DEFINITION TEXT NODE HERE <br/> <br/> <i> WORD </i> DEFINITION TEXT NODE HERE </a></p>\[/code\]My goal is to get this into our current DTD standard of a definition list so my output looks something along these lines:\[code\]<p> WANT TO GRAB TEXT NODE HERE </p><dl> <dlentry> <dt><i> WORD </i></dt> <dd> ANOTHER TEXT NODE HERE <dd> <dt><i> WORD </i></dt> <dd> ANOTHER TEXT NODE HERE <dd> <dlentry><dl>\[/code\]Here is a code snippet from my current transform:\[code\]**<xsl:template match="a/text()[1]"> <p> <xsl:value-of select="." /> </p> </xsl:template>**<xsl:template match="p[string-length(.) gt 600]"> <dl> <dlentry> <xsl:apply-templates /> </dlentry> </dl></xsl:template><xsl:template match="i"> <dt> <i> <xsl:value-of select="."/> </i> </dt></xsl:template><xsl:template match="text()[preceding-sibling::*[1][self::i]]"> <dd> <xsl:value-of select="normalize-space()"/> </dd></xsl:template>\[/code\]The problem is in the my "a" template that has the ** asterisks, where the XPath "a/text()[1]" isn't matching the text node that I want ("WANT TO GRAB TEXT NODE HERE").I have tried different XPath expressions there to no avail:\[code\]a[./*[1]][self::text()]a/text()[following-sibling::node()[1]/self::br and following-sibling::node()[2]/self::br]\[/code\]Any suggestions to what the XPath would be? Or if I need to tweak my XSLT?Thanks in advance.
 
Back
Top