You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Guy Sharon <gu...@hotmail.com> on 2003/11/10 10:56:04 UTC
DOMResult according to schema
Hi,
(Two part question)
How do I make sure the DOM tree held by the DOMResult object after
transformation complies to an XML Schema? (e.g. to the eg.xsd schema below)
I have the following in xsl
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xmlns">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
<root xmlns="http://example"
xmlns:eg="http://example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://example file:eg.xsd">
...
</root>
...
</xsl:transform>
Second part:
How do I use a grammar pool (preparsed schema) to have the DOMResult comply
to.
Thanks,
Guy
_________________________________________________________________
Frustrated with dial-up? Get high-speed for as low as $26.95.
https://broadband.msn.com (Prices may vary by service area.)
Re: DOMResult according to schema
Posted by Jeff Greif <jg...@alumni.princeton.edu>.
The xerces support for DOM Level 3 allows you to validate a document that
has already been parsed into a DOM. The xerces FAQ re DOM covers this. The
xerces FAQ re grammars explains how to preparse and pool grammars.
Jeff
----- Original Message -----
From: "Mike Rawlins" <mc...@rawlinsecconsulting.com>
To: <xa...@xml.apache.org>
Sent: Monday, November 10, 2003 7:29 AM
Subject: Re: DOMResult according to schema
> Guy,
>
> Part 1 of your question really has nothing to do with Xalan, per
> se. You're asking how to validate an XML instance document, as a DOM
tree,
> against its schema. This depends entirely on your DOM
> implementation. But, assuming you're using JAXP and Xerces, without using
> Xerces-specific classes there aren't very many really graceful or
efficient
> ways to do it.
...
> At 04:56 AM 11/10/2003 -0500, Guy Sharon wrote:
> >Hi,
> >
> >(Two part question)
> >
> >How do I make sure the DOM tree held by the DOMResult object after
> >transformation complies to an XML Schema?
...
> >Second part:
> >How do I use a grammar pool (preparsed schema) to have the DOMResult
> >comply to.
Re: DOMResult according to schema
Posted by Joseph Kesselman <ke...@us.ibm.com>.
XSLT 2.0 and XQuery (still only Working Drafts) were considering offering
the ability to validate document structures on demand. This was a somewhat
contentious issue, though, and I'm not sure whether that is in, or out, of
either draft at this point.
We experimented with a prototype of that function, but I don't believe it's
present in the current main-line Xalan code. It requires rather deep
dependencies upon Xerces (with the obvious portability concern), unless
you're willing to write the document out to a file, validate it there, and
read it back in (doable, but *slow*)
______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
Re: DOMResult according to schema
Posted by Mike Rawlins <mc...@rawlinsecconsulting.com>.
Guy,
Part 1 of your question really has nothing to do with Xalan, per
se. You're asking how to validate an XML instance document, as a DOM tree,
against its schema. This depends entirely on your DOM
implementation. But, assuming you're using JAXP and Xerces, without using
Xerces-specific classes there aren't very many really graceful or efficient
ways to do it. One way that I've done it is to serialize the DOM document
into a stream buffer, then read/parse/validate the stream buffer into
another DOM tree in the same way you might process an instance document
from a disk file or another URL.
If you want to validate using the Xerces-specific classes, you might post
this question to the Xerces-J list. I think that might also be a more
appropriate place to get an answer to part 2 of your question.
Mike
At 04:56 AM 11/10/2003 -0500, Guy Sharon wrote:
>Hi,
>
>(Two part question)
>
>How do I make sure the DOM tree held by the DOMResult object after
>transformation complies to an XML Schema? (e.g. to the eg.xsd schema below)
>
>I have the following in xsl
><xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0"
> xmlns:xalan="http://xml.apache.org/xslt"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> exclude-result-prefixes="xmlns">
>
> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
> <root xmlns="http://example"
> xmlns:eg="http://example"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://example file:eg.xsd">
> ...
> </root>
> ...
></xsl:transform>
>
>Second part:
>How do I use a grammar pool (preparsed schema) to have the DOMResult
>comply to.
>
>Thanks,
>Guy
>
>_________________________________________________________________
>Frustrated with dial-up? Get high-speed for as low as $26.95.
>https://broadband.msn.com (Prices may vary by service area.)
---------------------------------------------------------------
Michael C. Rawlins, Rawlins EC Consulting
www.rawlinsecconsulting.com
Using XML with Legacy Business Applications (Addison-Wesley, 2003)
www.awprofessional.com/titles/0321154940