Aw: Re: XSL

[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Aw: Re: XSL | index-of()

Subject: Aw: Re: XSL | index-of()
From: "Janine S. loderndesfeuer@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 27 Sep 2019 12:05:33 -0000
Aw: Re:  XSL | index-of()
Hello 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=""
xmlns:fn="" 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"/>
<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="."/>
</xsl:stylesheet> Many greetings
Janine Gesendet: Freitag, 27. September 2019 um 12:46 Uhr
Von: "Mukul Gandhi gandhi.mukul@xxxxxxxxx"
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: Re:  XSL | index-of()Hi Janine, Here's the stylesheet that
works, <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""
 exclude-result-prefixes="xs fn"

<xsl:output method="xml" indent="yes"/>

<xsl:template match="all">
<xsl:for-each select="documents/doc[fn:isIncludeDoc(.)]">
 <doc no="{@no}"><xsl:value-of
select="substring-before(substring-after(., '('), ')')"/></doc>

<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:stylesheet> On Fri, Sep 27, 2019 at 2:37 PM Janine Lantzsch
loderndesfeuer@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

  Hello community, I am new in this list and hope very much that
  someone can help me or give me an input with which I can continue to
  I would like to use XSL to check whether a abbreviation from a list
  appears in a certain string of recurring elements. The abbreviation
  is always written in brackets. The source file looks like this (very
  simplified): <?xml version="1.0" encoding="UTF-8"?>
   <doc no="1">The abbreviation (ABG) appears in this doc.</doc>
   <doc no="2">This doc has no shortcut.</doc>
   <doc no="3">An abbreviation (BBL).</doc>
   <doc no="4">And here (ECK).</doc>
   <doc no="5">And here again (ECK).</doc>
  Only unfortunately I still have a bug somewhere with the index-of.
  Maybe the more experienced of you will see right away what's wrong
  with my code. I've been brooding since last night and can't find a
  solution :( <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet xmlns:xsl=""
  xmlns:fn="" version="2.0">
   <xsl:output method="xml" encoding="UTF-8"/>
   <xsl:template match="all">
   <xsl:variable name="abbr" select="abbreviations/abbr"/>
   <xsl:for-each select="//doc">
   <xsl:variable name="actdoc" select="."/>
   <xsl:if test="fn:contains($actdoc, fn:index-of($abbr, $actdoc))">
   <xsl:attribute name="no"><xsl:value-of
   <xsl:value-of select="$actdoc"/>
  The output should look something like this: <all>
   <doc no="1">ABG</doc>
   <doc no="3">BBL</doc>
   <doc no="4">ECK</doc>
   <doc no="5">ECK</doc>
  Thank you so much for your help! Many greetingsJanine S.

-- Regards,
Mukul GandhiXSL-List info and archiveEasyUnsubscribe (by email) XSL-List
info and archiveEasyUnsubscribe (by email)

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.