Of course, if you're not designing the XML, then you don't get any choice in the matter - I was just saying that I don't think using xsi:nil is good design.
If it's not working under Saxon-SA then you're probably not pressing the right buttons to get schema-validated input.
I would try it from the command line first: make sure saxon9sa.jar is on the classpath, and use the option -val:strict on the command line.
If you want to do this using JAXP interfaces alone, then
(a) make sure you are using com.saxonica.SchemaAwareTransformerFactory,
(b) call factory.setAttribute(FeatureKeys.SCHEMA_VALIDATION_MODE, "strict")
Before playing with fn:nilled, try something simpler like
<xsl:template match="/">
  <xsl:message><xsl:value-of select="* instance of schema-element(my:top-level-element)"/></xsl:message>
which will say "true" if the input has been successfully validated.
Michael Kay

From: Fernando Ribeiro [mailto:webmaster@fernandoribeiro.eti.br]
Sent: 30 January 2009 02:37
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Use of fn:nilled

Actually it is useful in SOA applications, because there are several platforms (Progress OpenEdge, used by thousands of companies everywhere, for example) that send null fields as xsi:nil elements instead of omitting them, and require xsi:nil elements to be sent when fields are null. When working with these platforms, you might want to check for xsi:nil elements and either remove or transform them to something else.
The fn:nilled function is a better solution than @xsi:nil = 'true', the de facto workaround. Since my last post, I've tried getting it to work with both Saxon-B and Saxon-SA without success, though I may have insisted to use JAXP (DocumentBuilderFactory with Schema and XMLReader with ValidationHandler) for too long. Let me know if I should try the Saxon API instead.
If you want more information about use cases like this, we can talk off-list.
On Thu, Jan 29, 2009 at 9:30 PM, Michael Kay <mike@saxonica.com> wrote:
The simplest way of explaining fn:nilled() is that it returns true if two conditions are satisfied:
 (a) the element specifies xsi:nil="true"
 (b) the element is validated against a schema
To be honest, I don't know of any practical use case for this function. I think that the "nilled" property was needed in the data model to make the formal semantics work, and having got the property in the data model, people felt it ought to be accessible to applications. If you find a good use for it, let me know, because I can't think of one!
Generally xsi:nil is a bit of a disaster anyway. I don't see why you can't represent absent data by omitting the element, rather than having it present with no value.
Michael Kay

From: Fernando Ribeiro [mailto:webmaster@fernandoribeiro.eti.br]
Sent: 29 January 2009 16:57

To: Mailing list for the SAXON XSLT and XQuery processor
Subject: [saxon] Use of fn:nilled

I've been trying to use the nilled function but it seems like I am missing something about it. I'd appreciate if you could take a look at the attached example and find out why it doesn't work as expected.
Note that there ain't a schema (with nillable=true) attached to the source, as in the actual case (ain't an option) upon which the example is based.
The only reference I could find for problems with nilled is http://sourceforge.net/tracker2/?func=detail&aid=1717100&group_id=29872&atid=397617, but it is already closed.
I am currently using, which is embedded with the runtime in question.

This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
saxon-help mailing list archived at http://saxon.markmail.org/