catch 20 20,catch 20,what is catch 20,xsl template match catch all,xslt catch all,catch all rules,xsl catch all template,meaning of catch 20 20,catch 20 meaning,catch 21 meaning, xml%%%catch 20 20 - Re: Catch ALL

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

Re: Catch ALL | Failed template rule

Subject: Re: Catch ALL | Failed template rule
From: Karl Stubsjoen <kstubs@xxxxxxxxx>
Date: Tue, 22 Mar 2005 12:49:59 -0700
catch 20 20
Consider the following:


Transform XML into XML.  The resulting XML will be a series of pass
and fails where specific template rules have a match.  So you might be
asking questions like, does my element have an attribute "a" who's
value is "b"?  Or actually, you'd ask the question:  if my element has
an attribute "a" who's value is "b" then append the attribute "pass" =
"1" to the resulting XML, otherwise, append the attribute "pass" =
"0".

Example XML:
<foo>
  <bar a="c"/>
  <bar a="b"/><!-- passes -->
  <bar a="a"/>
  <bar a="b"/><!-- passes -->
</abc>

You would then:
<xsl:apply-template select="foo/bar[@a='b']" mode="matchedresults"/>

And match on:
<xsl:template match="bar" mode="matchedresults">
  <!-- append element "pass" = "1"-->
</xsl:template>

At this point, there is no way to have an "unmatched" template result,
and this does make sense to me.  I guess I was looking for the
cleanest way to exercise this.  I guess it would be this:
<xsl:apply-template select="not(foo/bar[@a='b'])" mode="unmatchedresults"/>


On Tue, 22 Mar 2005 18:12:57 +1100, Dimitre Novatchev
<dnovatchev@xxxxxxxxx> wrote:
> I know that the OP meant something completely different, but probably
> what seems as an appropriate  answer to the question expressed in the
> title of this thread is:
> 
>   the builtin rules.
> 
> It is a good practice to have them explicitly in one's code (with the
> least priority possible) and to put breakpoints on them (in a good
> XSLT IDE with a debugger), whenever one gets unexpected output that no
> other template is supposed to produce.
> 
> I find this meaning of "catch all" more natural and intuitive.
> 
> Cheers,
> Dimitre Novatchev.
> 
> 
> On Mon, 21 Mar 2005 08:03:06 -0700, Karl Stubsjoen <kstubs@xxxxxxxxx> wrote:
> > I'd like a catch ALL template rule, actually a catch NOT template
> > rule.  In an effort to check for the existence of a select, I have
> > setup a match template rule that simply returns "1" for a match.  So I
> > have:
> >
> > <xsl:template match="record" mode="recordexists">
> > <xsl:text>1</xsl:text>
> > </xsl:template>
> >
> > The failed select would need to return a "0".  So I need a match that
> > simply returns 0.
> >
> > So something like:
> >
> > <xsl:template match="not(record)" mode="recordexists">
> > <xsl:text>0</xsl:text>
> > </xsl:template>
> >
> > (which is not a legal match statement, but that is what I need).  I'm
> > sure there is a way, and I'm sure it is obvious!  Just not coming to
> > me.
> >
> > Thanks,
> > Karl

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.