> -----Original Message-----
> From: Clive Hughes [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 01, 2003 11:43 AM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] Validating XML documents and namespaces
>
>
> I am using Castor 0.9.5 and am only interested in
> unmarshalling at the
> moment. I can correctly unmarshal an XML document that
> is not validated or
> has no namespace details.
> However, moving on to validate and to handle
> namespaces, I run into
> difficulty. Sample of the XML below:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <AccCard>
> <Header>
> <Filename>abc.xml</Filename>
> <UserID>fred_bloggs</UserID>
> </Header>
> </AccCard>
>
> Firstly assume the submitted document is not validated.
> How can I prompt
> Castor to validate it against, say, AccCard.xsd on my
> local filesystem.
Look at the castor.properties files. Here is a snippet:
# True if xml documents should be validated by the SAX Parser
#
org.exolab.castor.parser.validation=false
org.exolab.castor.parser.namespaces=false
If you use .java files generated by the SourceGenerator,
you can use Castor schema validatoin, which is a lot faster than the parser's
validation.
Use this property from the same file:
# True if all documents should be validated by the marshalling framework
#
org.exolab.castor.marshalling.validation=true
>
> Secondly how would I get Castor to handle the case
> where a user submits this
> document with namespace information e.g.
Look at the nspackages attribute in the castorbuilder.properties file:
# XML namespace mapping to Java packages
#
#org.exolab.castor.builder.nspackages=\
http://www.xyz.com/schemas/project=com.xyz.schemas.project,\
http://www.xyz.com/schemas/person=com.xyz.schemas.person
Again, this is if you use the SourceGenerator.
If you don't, the mapping file can help.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <p:AccCard xmlns:p="urn:nmspace.co.uk"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="urn:nmspace.co.uk ChargeCard.xsd ">
> <p:Header>
> <p:Filename>abc.xml</p:Filename>
> <p:UserID>fred_bloggs</p:UserID>
> <p:/Header>
> <p:/AccCard>
>
> i.e. how do I handle (ignore) the xmlns attributes and
> p: namespace
> prefixes? My current mapping (which works fine without
> the p: prefix)
> doesn't handle this.
>
> Any help is appreciated, thanks
>
> Clive
>
> ________________________________________________________
> _________
> Use MSN Messenger to send music and pics to your friends
> http://www.msn.co.uk/messenger
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
>
> DISCLAIMER:
> This email message is for the sole use of the intended
> recipient(s) and may contain confidential and
> privileged information. Any unauthorized review, use,
> disclosure or distribution is prohibited. If you are
> not the intended recipient, please contact the sender
> by reply email and destroy all copies of the original
> message and attachments.
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev