You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Lauren Bish <lc...@developerdude.org> on 2005/06/23 19:59:17 UTC
XML Schema validation without XSD file but with XSD in memory??
While people are thinking about XSD, is there a way to have Xerces
validate an XML blob using an in memory definition of an XSD?
I surfed around in the JavaDocs and didn't see any obvious way of
constructing an XSD on the fly, and handing it to Xerces to use to
validate an XML blob. The closest I could find was SchemaGrammar.
Excuse me if this obvious to others, it just isn't to me as I am new to
XML, XSD and Xerces. If there are any examples of how to do this I would
appreciate a link.
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: XML Schema validation without XSD file but with XSD in memory??
Posted by Lauren Bish <lc...@developerdude.org>.
Thanks George,
That helps a lot. What I have is a class that, on the fly (i.e., can
change dynamically from one instant to the next), defines a structure
against which I need to validate a given subset of XML - so I need to
convert that class into an in memory XSD and then hand that to the
parser. I was thinking that instead of creating an XSD file from my
class, that I could somehow take my class and create the XSD in memory
without having to create a string representation of the XSD.
But I will figure it out with that link I think - apparently the object
I want to create either a org.apache.xerces.xni.grammars.XSGrammar;
or an org.apache.xerces.xs.XSModel.
George Cristian Bina wrote:
> Hi Lauren,
>
> For validating a document with a specified schema see
> http://xml.apache.org/xerces2-j/faq-grammars.html
>
> If you have the schema document as a String in memory then you can very
> easily feed that to the parser. The parser needs an InputSource and that
> does not require a file, you can set directly a Reader that can be a
> StringReader created over the String that represents your schema.
>
> Hope that helps,
> George
> ---------------------------------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: XML Schema validation without XSD file but with XSD in memory??
Posted by George Cristian Bina <ge...@sync.ro>.
Hi Lauren,
For validating a document with a specified schema see
http://xml.apache.org/xerces2-j/faq-grammars.html
If you have the schema document as a String in memory then you can very
easily feed that to the parser. The parser needs an InputSource and that
does not require a file, you can set directly a Reader that can be a
StringReader created over the String that represents your schema.
Hope that helps,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Lauren Bish wrote:
> While people are thinking about XSD, is there a way to have Xerces
> validate an XML blob using an in memory definition of an XSD?
>
> I surfed around in the JavaDocs and didn't see any obvious way of
> constructing an XSD on the fly, and handing it to Xerces to use to
> validate an XML blob. The closest I could find was SchemaGrammar.
>
> Excuse me if this obvious to others, it just isn't to me as I am new to
> XML, XSD and Xerces. If there are any examples of how to do this I would
> appreciate a link.
>
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org