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

RE: Pattern Matching in XSl - find groups defined in o

Subject: RE: 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
RE:  Pattern Matching in XSl - find groups defined in o
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: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 ?

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.