A
Andreas Kraftl
Hello,
i've a xml file:
<lexikon>
<begriff>
<synonyme>
<synonym>a</synonym>
<synonym>b c</synonym>
</synonym>
<beschreibung>
Great letters.
</beschreibung>
</begriff>
...
</lexikon>
Then there is an other XML file where i would every string from <synonym>
extending.
Example XML file:
There is an b c and there an a
should be extend to
There is an
<a href="lexikon.php" class="lexikon">b c<span>
Great letters.</span></a>
and there an <a href="lexikon.php" class="lexikon">a<span>
Great letters.</span></a>
Following works not:
<!-- build the regex string -->
<xsl:variable name="lexwordstring">
<xsl:text>(.*?)(nurDummText</xsl:text>
<xsl:for-each
select="/pages/page/content/lexikon/begriff/synonyme/*">
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(.)"/>
</xsl:for-each>
<xsl:text>)([ ,.]*?)</xsl:text>
</xsl:variable>
<xsl:template match="text()">
<xsl:analyze-string select="." regex="{$lexwordstring}">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"/>
<a href="{$lexikonpage}" class="lexikon">
<xsl:value-of select="regex-group(2)"/>
<span>
<xsl:apply-templates select="..."/>
</span>
</a>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
Saxon means with <xsl:apply-templates>
"Cannot select a node here: the context item is an atomic value"
Without <xsl:apply-templates>, it works, but without the description .
Every idea is welcome?
Thanks
Andy
i've a xml file:
<lexikon>
<begriff>
<synonyme>
<synonym>a</synonym>
<synonym>b c</synonym>
</synonym>
<beschreibung>
Great letters.
</beschreibung>
</begriff>
...
</lexikon>
Then there is an other XML file where i would every string from <synonym>
extending.
Example XML file:
There is an b c and there an a
should be extend to
There is an
<a href="lexikon.php" class="lexikon">b c<span>
Great letters.</span></a>
and there an <a href="lexikon.php" class="lexikon">a<span>
Great letters.</span></a>
Following works not:
<!-- build the regex string -->
<xsl:variable name="lexwordstring">
<xsl:text>(.*?)(nurDummText</xsl:text>
<xsl:for-each
select="/pages/page/content/lexikon/begriff/synonyme/*">
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(.)"/>
</xsl:for-each>
<xsl:text>)([ ,.]*?)</xsl:text>
</xsl:variable>
<xsl:template match="text()">
<xsl:analyze-string select="." regex="{$lexwordstring}">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"/>
<a href="{$lexikonpage}" class="lexikon">
<xsl:value-of select="regex-group(2)"/>
<span>
<xsl:apply-templates select="..."/>
</span>
</a>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
Saxon means with <xsl:apply-templates>
"Cannot select a node here: the context item is an atomic value"
Without <xsl:apply-templates>, it works, but without the description .
Every idea is welcome?
Thanks
Andy