Aw: Re: [xsl] XSL | index-of()2019-09-27 07:05:40Hello everybody and thank you very much for your good answers. They help me to better understand XSL. I was also able to help myself with two for-each loops:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" version="2.0" exclude-result-prefixes="#all"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="all">
<xsl:variable name="abbr" select="abbreviations/abbr"/> <all> <xsl:for-each select="//doc"> <xsl:variable name="actdoc" select="."/> <xsl:variable name="no" select="@no"/> <xsl:for-each select="$abbr"> <xsl:if test="fn:contains($actdoc, .)"> <doc no="{$no}"> <xsl:value-of select="."/> </doc> </xsl:if> </xsl:for-each> </xsl:for-each> </all> </xsl:template> </xsl:stylesheet> Many greetings
Janine Gesendet: Freitag, 27. September 2019 um 12:46 Uhr
Von: "Mukul Gandhi gandhi(_dot_)mukul(_at_)gmail(_dot_)com" <xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com Betreff: Re: [xsl] XSL | index-of() Hi Janine,
Here's the stylesheet that works,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://stylesheet_fns" exclude-result-prefixes="xs fn" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="all"> <all> <xsl:for-each select="documents/doc[fn:isIncludeDoc(.)]"> <doc no="{@no}"><xsl:value-of select="substring-before(substring-after(., '('), ')')"/></doc> </xsl:for-each> </all> </xsl:template> <xsl:function name="fn:isIncludeDoc" as="xs:boolean"> <xsl:param name="doc" as="element(doc)"/> <xsl:sequence select="some $abbr in $doc/../../abbreviations/abbr satisfies contains($doc, concat('(', $abbr, ')'))"/> </xsl:function> </xsl:stylesheet> On Fri, Sep 27, 2019 at 2:37 PM Janine Lantzsch loderndesfeuer(_at_)gmx(_dot_)de <xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Regards,
Mukul Gandhi
|
|