Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > DTD to XML

Reply
Thread Tools

DTD to XML

 
 
Ritu
Guest
Posts: n/a
 
      09-02-2004
Hello Folks,

I am struggling to convert an existing DTD file to the XSD format. I
encountered some problems and was hoping someone could help me out
here.

I am using XMLspy to create the schema.

My original DTD statement looks like this

<!ELEMENT AC_RECORD_ID (#PCDATA)>
<!ATTLIST AC_RECORD_ID
e-dtype NMTOKEN #FIXED "int"
>




In XSD I represent this by adding an atrribute to the AC_RECORD_ID
element as in

<xs:complex type name="PHRASE">
<xs:sequence>
<xs:element name="AC_RECORD_ID">
<xs:complexType>
<xs:attribute name="e-dtype" type="xs:NMTOKEN" fixed="int"/>
</xs:complexType>
</xs:element>
.... other elements
</xs:sequence>
</xs:complexType>

When I try to validate my XML against this I get the following error

"unexpected element contents - AC_RECORD_ID is defined as EMPTY"

The XML block that gives this error is

<AC_RECORD_ID>124</AC_RECORD_ID>


My problem is that I have not defined AC_RECORD_ID to be empty
anywhere. Why does adding an attribute to it trigger this error?. Is
there something missed out in the definition? If I remove the
attribute the XML piece validates without problem.

I would really appreciate any pointers in this direction.

Cheers
Ritu
 
Reply With Quote
 
 
 
 
Ed Day
Guest
Posts: n/a
 
      09-03-2004
I think the problem is that you do not have any content defined for
the element. Therefore, the only thing that is allowed is a null
element with a single attribute. You can use simpleContent to add an
attribute to a simple base type as follows:

<xs:complex type name="PHRASE">
<xs:sequence>
<xs:element name="AC_RECORD_ID">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="e-dtype" type="xs:NMTOKEN"
fixed="int"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
... other elements
</xs:sequence>
</xs:complexType>

Regards,

Ed Day
Objective Systems, Inc.


http://www.velocityreviews.com/forums/(E-Mail Removed) (Ritu) wrote in message news:<(E-Mail Removed). com>...
> Hello Folks,
>
> I am struggling to convert an existing DTD file to the XSD format. I
> encountered some problems and was hoping someone could help me out
> here.
>
> I am using XMLspy to create the schema.
>
> My original DTD statement looks like this
>
> <!ELEMENT AC_RECORD_ID (#PCDATA)>
> <!ATTLIST AC_RECORD_ID
> e-dtype NMTOKEN #FIXED "int"
> >

>
>
>
> In XSD I represent this by adding an atrribute to the AC_RECORD_ID
> element as in
>
> <xs:complex type name="PHRASE">
> <xs:sequence>
> <xs:element name="AC_RECORD_ID">
> <xs:complexType>
> <xs:attribute name="e-dtype" type="xs:NMTOKEN" fixed="int"/>
> </xs:complexType>
> </xs:element>
> ... other elements
> </xs:sequence>
> </xs:complexType>
>
> When I try to validate my XML against this I get the following error
>
> "unexpected element contents - AC_RECORD_ID is defined as EMPTY"
>
> The XML block that gives this error is
>
> <AC_RECORD_ID>124</AC_RECORD_ID>
>
>
> My problem is that I have not defined AC_RECORD_ID to be empty
> anywhere. Why does adding an attribute to it trigger this error?. Is
> there something missed out in the definition? If I remove the
> attribute the XML piece validates without problem.
>
> I would really appreciate any pointers in this direction.
>
> Cheers
> Ritu

 
Reply With Quote
 
 
 
 
Ritu
Guest
Posts: n/a
 
      09-08-2004
(E-Mail Removed) (Ed Day) wrote in message news:<(E-Mail Removed). com>...
> I think the problem is that you do not have any content defined for
> the element. Therefore, the only thing that is allowed is a null
> element with a single attribute. You can use simpleContent to add an
> attribute to a simple base type as follows:


Thanks Ed, this does work!

Regards
Ritu
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML file from one DTD to another DTD test Java 2 07-28-2006 08:48 PM
How to specify DTD to DTD.getDTD for DocumentParser? Ronald Fischer Java 4 03-17-2005 09:37 AM
Removing the dtd name when using print(...) on the dtd generated class Joseph Tilian Java 0 12-21-2004 02:58 PM
Validating XML against a DTD that is not supplied in the XML Schema Ben Jessel Java 0 08-05-2004 11:45 AM
Including a dtd into another dtd... possible? Asfand Yar Qazi XML 1 09-19-2003 12:10 PM



Advertisments