Reputation: 11
I have the following xml and I need to extract the text that is outside the node "justified".
<html><head><title>test</title></head><body><p><justificado><negrita>TEST.- </negrita>Hello people <negrita>it is</negrita><negrita>,</negrita> fa test ./justificado></p></body></html>
I have tried without success the following
<xsl:template match="not (*/negrita[preceding-sibling::*[1]self::negrita]])">test-123</xsl:template>
Upvotes: 1
Views: 432
Reputation: 116982
I need to extract the text that is outside the node "justified".
The default behavior of an XSLT stylesheet is to copy all text nodes - so in order to extract all text that is outside a specific element, you only need an empty template matching the text nodes that are inside the specified element:
XSLT 1.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="text()[ancestor::justificado]"/>
</xsl:stylesheet>
Applied to your example input (after correcting the closing </justificado>
tag!), the result is:
test
Upvotes: 1