You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Radu Preotiuc-Pietro <ra...@bea.com> on 2007/06/02 02:18:05 UTC

Re: Question about validating a XmlObject

Also, if you have programatically compiled your Schema, you should have
a reference to a SchemaTypeSystem object.

XmlObject xml = schemaTypeSystem.parse(xmlFile)

will make sure that the "xml" XmlObject has the right type from the
beginning.

Radu

On Thu, 2007-05-31 at 14:33 -0700, Jacob Danner wrote:
> Hi Patrizio,
> There is a method on the XmlObject class that should allow the
> functionality you are looking for. The method is changeType().
> 
>  XmlObject 	changeType(SchemaType newType)
>           Changes the schema type associated with this data and
> returns a new XmlObject instance whose schemaType is the new type.
> 
> http://xmlbeans.apache.org/docs/2.2.0/reference/org/apache/xmlbeans/XmlObject.html#changeType(org.apache.xmlbeans.SchemaType)
> Please let the list know if you have any other problems.
> Thanks,
> -Jacob Danner
> 
> 
> On 5/31/07, Patrizio.Ferlito@b-source.ch <Pa...@b-source.ch> wrote:
> > Hi all,
> >
> > I would like to validate a xml document against a given xsd.
> > My xml document doesn't contain any xsi:schemaLocation but the given xsd
> > is well known.
> >
> > Below I reported a piece of code:
> >
> >   File xmlFile = new File(xmlFilePath);
> >   XmlObject xml = XmlObject.Factory.parse(xmlFile);
> >
> >   System.out.println("Schema type: " + xml.schemaType()); //output is
> > 'Schema type: N='
> >
> >   // Validate the XML.
> >   boolean isValid = xml.validate(validateOptions);
> >
> > If I know what is the given xsd (xsdFilePath), how can I specify what
> > xsd to be used ?
> > Is there any setSchemaType() / assignSchemaType() ?
> >
> > Thanks
> > Patrizio
> >
> > IMPORTANT:
> > This e-mail transmission is intended for the named
> > addressee(s)only.
> > Its contents are private, confidential and protected
> > from disclosure and should not be read, copied or
> > disclosed by any other person.
> > If you are not the intended recipient, we kindly ask
> > you to notify the sender immediately by telephone
> > (+41 (0)58 806 50 00), to redirect the message to the
> > account "info@b-source.ch" and to delete this e-mail.
> > E-mail transmissions may be intercepted, altered or
> > read by unauthorized persons and may contain viruses.
> > Therefore, it is recommended that you use regular mail
> > or courier services for any information intended to be
> > confidential. However, by sending us messages through
> > e-mail, you authorize and instruct us to correspond by
> > e-mail in the relevant matter.
> > Thank you.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org