Solved

dtd and xml not jiving

Posted on 2011-03-03
5
325 Views
Last Modified: 2012-05-11
So I have an xml feed that I am getting from another system and so I created a dtd as part of the mapping process on my end.  However right now they dont like each other.  I have been starring at this for a while and I need to see if someone can point out the error of my ways.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ItemInquiry SYSTEM "ItemInquiry.dtd" > 
<ItemInquiry> 
<Code="7VQ"  Item="ST4006"  Dollars="228.00"  Error="S" /> 
<Code="XXX"  Item="6444.54"  Dollars="44.95"  Error="X" /> 
<Code="QFY"  Item"ST2753D"  Dollars="228.00"  Error=" " /> 
<Code="WTF"  Item="ST4006"  Dollars="168.00"  Error=" " /> 
</ItemInquiry> 


<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT ItemInquiry ( Code | Item | Dollars | Error )* >
<!ELEMENT Code ( #PCDATA ) >
<!ELEMENT Item ( #PCDATA ) >
<!ELEMENT Dollars ( #PCDATA ) >
<!ELEMENT Error ( #PCDATA ) >

Open in new window

0
Comment
Question by:iceman19330
  • 3
  • 2
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35026940
well, your XML is not wellformed,
you seem to have only attributes and no element name
You could rather mean something like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ItemInquiry SYSTEM "ItemInquiry.dtd" >
<ItemInquiry>
<Item Code="7VQ"  Name="ST4006"  Dollars="228.00"  Error="S" />
<Item Code="XXX"  Name="6444.54"  Dollars="44.95"  Error="X" />
<Item Code="QFY"  Name"ST2753D"  Dollars="228.00"  Error=" " />
<Item Code="WTF"  Name="ST4006"  Dollars="168.00"  Error=" " />
</ItemInquiry>


0
 

Author Comment

by:iceman19330
ID: 35026964
what would the dtd look like?

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT ItemInquiry ( Code | Name | Dollars | Error )* >
<!ELEMENT Code ( #PCDATA ) >
<!ELEMENT Name ( #PCDATA ) >
<!ELEMENT Dollars ( #PCDATA ) >
<!ELEMENT Error ( #PCDATA ) >
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 35026969
Having this as XML

<ItemInquiry>
    <Item Code="7VQ"  Name="ST4006"  Dollars="228.00"  Error="S" />
    <Item Code="XXX"  Name="6444.54"  Dollars="44.95"  Error="X" />
    <Item Code="QFY"  Name="ST2753D"  Dollars="228.00"   />
    <Item Code="WTF"  Name="ST4006"  Dollars="168.00"   />
</ItemInquiry>

This would be the DTD
<!ELEMENT ItemInquiry ( Item )* >
<!ELEMENT Item EMPTY  >
<!ATTLIST Item 
    Code CDATA #REQUIRED 
    Name CDATA #REQUIRED 
    Dollars CDATA #REQUIRED 
    Error (S | X ) #IMPLIED >

Open in new window

0
 

Author Comment

by:iceman19330
ID: 35027098
Thank you for the promptness and throughness of your answer.

Now with the Error do I just need to list the possible flags that come back in the DTD and if there is no flag then its blank but I dont need to do anything with that blank spot in the DTD?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35027463
Ah, the blank spot, You can't express the blank spot in a finite list
I made the attribute implied, so you can leave it out as an alternative to a blank spot
If you can't leave the attribute out as an alternative, you need to make it CDATA as the rest

   Error CDATA  #REQUIRED >
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now