Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - converting xml file to schema file problem

 
Thread Tools Search this Thread
Old 10-07-2009, 10:41 AM   #1
Default converting xml file to schema file problem


i am converting a xml file having namespaces in to schema file (.xsd)
for validation.

my xml file is
test.xml
-----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<root xmlnss="http://www.w3.org/2001/XMLSchema"
xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3.org/TR/scxml/">
<h:table>
<h:tr>vegitables</h:tr>
<h:td>Apples</h:td>
</h:table>

<f:table>
<f:name>African Coffee Table</f:name>
<f:data>hari</f:data>
<f:length>oum</f:length>
</f:table>
</root>
----------------------------------------------------------

I converted this xml file in to schema file.
test.xsd
----------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
xmlns:h="http://www.w3.org/TR/html4/"
xmlns:j="http://www.w3.org/TR/scxml/">
<xs:element name="root">
<xs:complexType>
<xs:sequence>

<xs:element name="h:table">
<xs:complexType>
<xs:sequence>
<xs:element name="h:tr" type="xs:string"/>
<xs:element name="h:td" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="f:table">
<xs:complexType>
<xs:sequence>
<xs:element name="f:name" type="xs:string"/>
<xs:element name="f:data" type="xs:string"/>
<xs:element name="f:length" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>
------------------------------------------------------------------
when i am validating this schema file
it is showing eroors in OUTPUT
-------------------------------------------------------------------
temp1.xsd:9: element element: Schemas parser error : Element '{http://
www.w3.org/2001/XMLSchema}element', attribute 'name': 'h:table' is not
a valid value of the atomic type 'xs:NCName'.

temp1.xsd:18: element element: Schemas parser error : Element '{http://
www.w3.org/2001/XMLSchema}element', attribute 'name': 'f:table' is not
a valid value of the atomic type 'xs:NCName'.

temp.xml:4: element root: Schemas validity error : Element 'root': No
matching global declaration available for the validation root.
temp.xml fails to validate
-------------------------------------------------------------------

I want to know that while converting above xml file to schema file, is
there
any problem or errer in converted schema file.
And i also want to know, that, why these error are coming and how to
overcome
these.

note: for validation we can use testSchema.c. which is in libxml2 api.

Thanks in advance


sharan
  Reply With Quote
Old 10-07-2009, 10:56 AM   #2
harry
 
Posts: n/a
Default Re: converting xml file to schema file problem
On Oct 7, 2:41 pm, sharan <harioumsha...@gmail.com> wrote:
> i am converting a xml file having namespaces in to schema file (.xsd)
> for validation.
>
> my xml file is
> test.xml
> -----------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlnss="http://www.w3.org/2001/XMLSchema"
> xmlns:h="http://www.w3.org/TR/html4/"
> xmlns:f="http://www.w3.org/TR/scxml/">
> <h:table>
> <h:tr>vegitables</h:tr>
> <h:td>Apples</h:td>
> </h:table>
>
> <f:table>
> <f:name>African Coffee Table</f:name>
> <f:data>hari</f:data>
> <f:length>oum</f:length>
> </f:table>
> </root>
> ----------------------------------------------------------
>
> I converted this xml file in to schema file.
> test.xsd
> ----------------------------------------------------------
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xs:schema xmlnss="http://www.w3.org/2001/XMLSchema"
> xmlns:h="http://www.w3.org/TR/html4/"
> xmlns:j="http://www.w3.org/TR/scxml/">
> <xs:element name="root">
> <xs:complexType>
> <xs:sequence>
>
> <xs:element name="h:table">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="h:tr" type="xs:string"/>
> <xs:element name="h:td" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> <xs:element name="f:table">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="f:name" type="xs:string"/>
> <xs:element name="f:data" type="xs:string"/>
> <xs:element name="f:length" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> </xs:schema>
> ------------------------------------------------------------------
> when i am validating this schema file
> it is showing eroors in OUTPUT
> -------------------------------------------------------------------
> temp1.xsd:9: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'name': 'h:table' is not
> a valid value of the atomic type 'xs:NCName'.
>
> temp1.xsd:18: element element: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'name': 'f:table' is not
> a valid value of the atomic type 'xs:NCName'.
>
> temp.xml:4: element root: Schemas validity error : Element 'root': No
> matching global declaration available for the validation root.
> temp.xml fails to validate
> -------------------------------------------------------------------
>
> I want to know that while converting above xml file to schema file, is
> there
> any problem or errer in converted schema file.
> And i also want to know, that, why these error are coming and how to
> overcome
> these.
>
> note: for validation we can use testSchema.c. which is in libxml2 api.
>
> Thanks in advance


Sorry by mistake it is showing different encoding in both file.
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="ISO-8859-1"?>

But i am using same encoding in both file, like:
<?xml version="1.0" encoding="UTF-8"?>


harry
  Reply With Quote
Old 10-07-2009, 12:34 PM   #3
Martin Honnen
 
Posts: n/a
Default Re: converting xml file to schema file problem
sharan wrote:
> i am converting a xml file having namespaces in to schema file (.xsd)
> for validation.
>
> my xml file is
> test.xml
> -----------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <root xmlnss="http://www.w3.org/2001/XMLSchema"
> xmlns:h="http://www.w3.org/TR/html4/"
> xmlns:f="http://www.w3.org/TR/scxml/">
> <h:table>
> <h:tr>vegitables</h:tr>
> <h:td>Apples</h:td>
> </h:table>
>
> <f:table>
> <f:name>African Coffee Table</f:name>
> <f:data>hari</f:data>
> <f:length>oum</f:length>
> </f:table>
> </root>


You will need three schemas, one for each namespace used (i.e. no
namespace for the root element and two different namespaces for the
other elements). Then the schema for the root element needs to import
the other two schemas and reference the type or element definitions in
those schemas.


--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/


Martin Honnen
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Converting VB to C# dodgerid Software 0 05-27-2009 02:30 AM
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
HELP ! - problem converting "windows movie maker" to "click to dvd" Terry Hoknes DVD Video 0 07-23-2004 06:17 AM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46