[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsd and org.apache.commons.digester.Digester


digester xsd
Hi Darren,

 > <!DOCTYPE uwaf-config PUBLIC
 >
 >         "-//UTRS//DTD Web Application Framework Configuration 1.0//EN"
 >
 >         "http://www.utrs.com/content/xsd/uwaf-config_1_0.xsd">

XML Schema can be associated with a document using the schema instance 
schemaLocation or noNamespaceSchemaLocation attributes. The DOCTYPE 
declaration is only for specifying a DTD.

Your document should start like below:

<uwaf-config
   xmlns="http://www.utrs.com/content/xml/xsd/uwaf/v10/config"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xsi:schemaLocation="http://www.utrs.com/content/xml/xsd/uwaf/v10/config 
http://www.utrs.com/content/xsd/uwaf-config_1_0.xsd"
  >

Of course, you can also specify the schema externally (that is not 
inside the document) if the API you use for validation allows you to do 
that.

Best regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Darren Hall wrote:
> Hi everyone,
> 
> I'm unable to parse an XML file I've created using the commons Digester 
> when I use an xsd file vs. a dtd file.
> 
> Is anyone aware of any known issues with this?
> 
>  
> 
> I'm using commons-digester-1.7. When I try to validate the xml file 
> against the xsd, I get the following error -
> 
>  
> 
> "2006-06-29 14:50:38,714 ERROR org.apache.commons.digester.Digester - 
> Parse Fatal Error at line 1 column 3: The markup declarations contained 
> or pointed to by the document type declaration must be well-formed.
> 
>  
> 
> org.xml.sax.SAXParseException: The markup declarations contained or 
> pointed to by the document type declaration must be well-formed."
> 
>  
> 
> The xml file seems to validate properly against a dtd. Also, the xsd 
> file is incomplete, I know, and I was expecting to get an error - just 
> not the one I got. The error I ended up getting when I tried to parse 
> the xml file leads me to believe there may be a problem with the 
> Digester working with xsd files. I just want to verify that this is the 
> case before I continue writing this xsd. If not, please let me know what 
> I'm doing wrong and I'll keep going. (The dtd I validated against was 
> complete - btw.)
> 
>  
> 
> Thanks,
> 
> Darren
> 
>  
> 
> Below are snippets of relevant code -
> 
>  
> 
> //Java code that creates the digester and calls parse
> 
> […]
> 
>         String configPath = "/WEB-INF/classes/uwaf-config.xml";
> 
>         digester = new Digester();
> 
>         digester.setNamespaceAware(true);
> 
>         digester.setValidating(this.isValidating());
> 
>         digester.setUseContextClassLoader(true);
> 
>         digester.addRuleSet(new ConfigRuleSet());
> 
>         digester.push(configPath);
> 
>  
> 
>         InputStream input = null;
> 
>         URL url = getServletContext().getResource(configPath);
> 
>         InputSource is = new InputSource(url.toExternalForm());
> 
>         input = url.openStream();
> 
>         is.setByteStream(input);
> 
>         digester.parse(is);
> 
> […]
> 
>  
> 
> //uwaf-config.xml
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> 
> <!DOCTYPE uwaf-config PUBLIC
> 
>         "-//UTRS//DTD Web Application Framework Configuration 1.0//EN"
> 
>         "http://www.utrs.com/content/xsd/uwaf-config_1_0.xsd">
> 
> <uwaf-config>
> 
>   <view-mappings type="com.utrs.framework.webapp.examples.PageProcessor">
> 
>     <view path="/home" forward="/home.jsp" >
> 
>         <set-property property="home" value="HOME" />
> 
>     </view>
> 
>   </view-mappings>
> 
> </uwaf-config>
> 
>  
> 
> //uwaf-config_1_0.xsd
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> 
> <xs:schema version="1.1"
> 
> targetNamespace="http://www.utrs.com/content/xml/xsd/uwaf/v10/config"
> 
>            xmlns:waf="http://www.utrs.com/content/xml/xsd/uwaf/v10/config/"
> 
>            xmlns:xs="http://www.w3.org/2001/XMLSchema"
> 
>            elementFormDefault="qualified" attributeFormDefault="qualified">
> 
>   <!-- definition of complex type elements -->
> 
>   <xs:element name="uwaf-config">
> 
>     <xs:complexType>
> 
>       <xs:sequence>
> 
>         <xs:element ref="waf:view-mappings" minOccurs="0" maxOccurs="1"/>
> 
>         <xs:attribute ref="waf:id"/>
> 
>       </xs:sequence>
> 
>     </xs:complexType>
> 
>   </xs:element>
> 
>   <!-- definition of simple type elements -->
> 
>   <xs:element name="view-mappings" type="xs:string"/>
> 
>   <!-- definition of simple type attributes --> 
> 
>   <xs:attribute name="id" type="xs:ID" use="optional"/>
> 
> </xs:schema>
> 
>  
> 

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.