Solved

dtd and xml not jiving

Posted on 2011-03-03
5
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

615 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