[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Testing if first child is text or an element?
On 15/04/2024 21:29, dvint@xxxxxxxxx wrote:
kyt1659720640909.dita -->I've got some markup that allows mixed content in an element. When I process this content I need to do something different if the element starts with text vs an element. My content can be like this: B B B B B B B B B B B B B B B <xsl:whentest="ancestor::*[contains(@outputclass, test="local-name()='info'">'collapse')]"/> B B B B B B B B B B B B B B B <xsl:otherwise> B B B B B B B B B B B B B B B B B B B <xsl:value-of select="$RETURN"/> B B B B B B B B B B B B B B B B B B B <xsl:choose> B B B B B B B B B B B B B B B B B B B B B B B <xsl:when test="child::*[1] instanceB B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:choose> B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:when do nothing for info elementof element()"> B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B <!-- test="child::*[1] instancewith content --> B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B </xsl:when> B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:when of text()"><xsl:value-of select="$RETURN"/> B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B </xsl:when> B B B B B B B B B B B B B B B B B B B B B B B B B B B </xsl:choose> child::* selects element nodesB only I think. But do realize that the second info element also starts with a pure whitespace text node child.
B B info[node()[1][normalize-space()] instance of text()]] or B B info[node()[1][normalize-space()][self::text()]] to match the info element that starts with a text node that has more than whitespace.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|