Solved

dtd and xml not jiving

Posted on 2011-03-03
5
330 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

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…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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