[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: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 29 Aug 2012 12:27:45 -0400

At 2012-08-29 16:16 +0000, 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:for-each select="regex-group(1)[normalize-space(.)]">
<xsl:attribute name="found-key" select="."/>

rather than

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


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

I am positioning the context to be the regex-group(1) string only if that string is non-empty (or, at least, not made entirely of white-space characters; if you want found white-space preserved, then replace normalize-space(.) with string(.) instead). If the string is empty, then I don't want to create the attribute. If the string is non empty, then I want to create the attribute with that string value, which is now the context.

In your example, matching "1 Alarm" that does not have any groups will create the empty attribute found-key="" ... which wasn't in your example of what you wanted. I understood you to want found-key= suppressed if there were no search strings in the content.

So your suggested code will create the empty found-key="" and mine will not.

I hope this is helpful.

. . . . . . . . . . Ken

-- Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread