logo       

Re: Why is Content Invalid????: msg#00029

Subject: Re: Why is Content Invalid????
Joey,

It's because element 'cwe' belongs in the "" namespace according to the
schema.  By default, the schema's elementFormDefault attribute is false.
This determines the qualification of local variables.  In your case, element
'cwe' is local (i.e., not direct child element of the 'schema' element) and
therefore should not be qualified.  However, in your instance doc, it has
the namespace xmlns="http://www.foo.com/ClinicalElement";.

So the parser is correctly flagging that your instance doc does validate
against the schema.

For more info, search for "elementFormDefault" in the XML Schema Specs:
http://www.w3.org/TR/xmlschema-0/

- Jeehong

----- Original Message -----
From: "Joey Coyle" <joey@xxxxxxxxxx>
To: <xerces-j-user@xxxxxxxxxxxxxx>
Sent: Friday, April 09, 2004 2:20 PM
Subject: Why is Content Invalid????


> I just can't figure out what the problem is here, but I assume it is
> some namespace problem.
>
> Here is the Error, and below is the Instance Document with the Schema,
> and finally the Method where I validate.
>
> [Error] Instance.xml:3:10: cvc-complex-type.2.4.a: Invalid content was
> found starting with element 'cwe'. One of '{"":cwe}' is expected.
>
>
> $$$$$$$$$$$$$$$$$$$$$$$$$$
>
> INSTANCE DOCUMENT
>
> <?xml version="1.0" encoding="UTF-8"?>
> <TransportWrapper xmlns="http://www.foo.com/ClinicalElement";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>      <cwe>hello</cwe>
> </TransportWrapper>
>
>
> $$$$$$$$$$$$$$$$$$
>
> SCHEMA
>
> <xs:schema targetNamespace="http://www.ihc.com/ClinicalElement";
> xmlns="http://www.foo.com/ClinicalElement";
> xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>
>      <xs:element name="TransportWrapper" type="ClinicalElement"/>
>
>      <xs:complexType name="ClinicalElement">
>          <xs:sequence>
>                      <xs:element name="cwe" type="xs:string"/>
>          </xs:sequence>
>      </xs:complexType>
>
> </xs:schema>
>
> $$$$$$$$$$$$$$$$$$$$
>
> CODE
>
>      public Document parse(String fileName)
>      {
>          DOMParser parser = new DOMParser();
>          Document doc = null;
>
>          setFeature(parser, "http://xml.org/sax/features/validation";,
> true);
>          setFeature(parser,
> "http://apache.org/xml/features/validation/schema";, true);
>         setFeature(parser,
> "http://apache.org/xml/features/validation/schema-full-checking";,
> true);
>
>          try
>          {
>              parser.setProperty(
>
> "http://apache.org/xml/properties/schema/external-schemaLocation";,
>                      "http://www.foo.com/ClinicalElement
> ClinicalElement.xsd");
>          }
>          catch (SAXNotRecognizedException e)
>          {
>              System.out.print("Unrecognized property: ");
>
> System.out.println("http://apache.org/xml/properties/schema/external-
> schemaLocation");
>          }
>          catch (SAXNotSupportedException e)
>          {
>              System.out.print("Unrecognized property: ");
>
> System.out.println("http://apache.org/xml/properties/schema/external-
> schemaLocation");
>          }
>
>
>
>          try
>          {
>              parser.parse(fileName);
>              doc = parser.getDocument();
>
>          }
>          catch (IOException ie)
>          {
>              System.out.println("Could not read file.");
>          }
>          catch (SAXException e)
>          {
>              System.out.print("Could not create Document: ");
>              System.out.println(e.getMessage());
>          }
>
>          return doc;
>      }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xxxxxxxxxxxxxx
> For additional commands, e-mail: xerces-j-user-help@xxxxxxxxxxxxxx
>
>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe