[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Pattern Matching in XSl - find groups defined in one Xml in another Xml.

Subject: Re: [xsl] Pattern Matching in XSl - find groups defined in one Xml in another Xml.
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 29 Aug 2012 12:29:09 -0400


This is an idiom we use to filter out values that have whitespace only.

normalize-space('   ') returns '', which (coerced to a Boolean
false) fails a test.

So regex-group(1)[normalize-space(.)] returns an empty sequence when the
value of regex-group(1) is an empty string or only whitespace.

Ken is going to a little extra trouble here to avoid getting

found-key=" "

when $thisGroupedAlarm/@equipment has " ".

In other words, it's defensive programming of the sort you learn to
write when you have to handle data sets that are not well-controlled (an
unfortunate fact of life). You can skip it if you know that your data is
good, and won't be throwing up such cases, or more generally if garbage-in/garbage-out is fine for you.


On 8/29/2012 12:16 PM, Kerry, Richard wrote:
Regarding Ken's solutions from last Wednesday (repeated below), why
is it :

<xsl:analyze-string select="$thisAlarm/@equipment"
regex="^{$thisGroupedAlarm/@equipment}$"> <xsl:matching-substring>
<xsl:for-each select="regex-group(1)[normalize-space(.)]">
<xsl:attribute name="found-key" select="."/> </xsl:for-each>
</xsl:matching-substring> </xsl:analyze-string>

rather than

<xsl:analyze-string select="$thisAlarm/@equipment"
regex="^{$thisGroupedAlarm/@equipment}$"> <xsl:matching-substring>
<xsl:attribute name="found-key" select="regex-group(1)"/>
</xsl:matching-substring> </xsl:analyze-string>


What does the [normalize-space(.)] predicate do for us ?

Uncertainly, Richard.

PS. By the way, this does seem to give the right results. I'm only
now getting back to looking at it and working out how it works,
having had a few days off over the (UK) Bank Holiday weekend.

-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread