xsl-list
[Top] [All Lists]

Re: [xsl] instance-of schema-element

2008-03-14 11:46:30
Hi Andrew,

I think you can accomplish what you want using lax validation and "instance of" in XPath 2.0. The basic idea would be to perform lax validation, and then check if the validation succeeded using "instance of".

John

Andrew Welch wrote:
On 14/03/2008, Florent Georges <lists(_at_)fgeorges(_dot_)org> wrote:
Andrew Welch wrote:

 > <xsl:if test="$foo instance of schema-element(foo)">

 > ...does that mean $foo is validated at that point?


  No.  That will test if the dynamic type of $foo already matches
 schema-element(foo).

hmmm thought so - how can I validate $foo without it causing the
transform to fail?

The problem I'm trying to solve is along the lines of:

- $foo and $bar are both hold very similar similar XML ( a before and
after view of some XML in fact)

- if $foo is valid and $bar isn't, output $foo and vice versa

- if both are valid apply an extra layer of logic to decide which is output

- if neither are valid output nothing

With this approach I need some way of validating the XML from within
the XSLT and then be able to handle any validation failures...
something like:

<xsl:variable name="foo" as="document-node(schema-element(foo))">
  <xsl:document validation="strict">
    <foo/>
  </xsl:document>
</xsl:variable>

...that won't cause the transform to fail, but allow me to test
whether $foo is valid.

Any ideas?



--
John Snelson, Oracle Corporation            http://snelson.org.uk/john
Berkeley DB XML:        http://www.oracle.com/database/berkeley-db/xml
XQilla:                                  http://xqilla.sourceforge.net

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--