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

Re: Avoiding boneheaded mistakes in XSLT?

Subject: Re: Avoiding boneheaded mistakes in XSLT?
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Wed, 29 Dec 2010 15:23:22 +0000
Re:  Avoiding boneheaded mistakes in XSLT?
On Wed, 29 Dec 2010 10:07:26 -0500
"G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:

>  Allow me to try again, please.
> 
> Consider an XML document whose content model for <a> is:  ( b, c?, d )
> 
> This is a valid instance:
> 
>    <a>
>      <b/>
>      <c/>
>      <d/>
>    </a>
> 
> But, this is also a valid instance:
> 
>    <a>
>      <b/>
>      <d/>
>    </a>
> 
> So, given the second instance, I run it against two stylesheets:
> 
> Stylesheet 1:
> 
>    <xsl:if test="not(a/c)">I'll make an assumption about a missing
> C</xsl:if>
> 
> Stylesheet 2 (with a typo in it because the user mistyped):
> 
>    <xsl:if test="not(a/cc)">I'll make an assumption about a missing
> C</xsl:if>
> 
> Without a schema to know that <cc> is not an acceptable element, 
> there is no way to distinguish the two above if statements.  With a 
> schema, the second one is clearly in error.  But without a schema, it 
> does not make sense to issue an error or warning about the first 
> stylesheet, because it is a bona fide test I want to perform 
> regarding the absence of <c>.  Hence, it cannot make the same 
> assumption about the second stylesheet, and so again cannot issue an 
> error or warning.


Again you're assuming the presence of a schema?
Review that given an input XML instance only.
The lack of a trigger for the xpath provides information
that is useful IMHO.

I'm not arguing that extra information may be gleaned from the Schema,
just that in many cases such a schema may not be available,
an instance being used is more usually available.





-- 

regards 

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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.