[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1574
  • Last Modified:

Convert DTD to XML Schema using XML spy

Hi experts,
                 I have a DTD that I want to convert into XML schema, So that I can use it with XMLBeans.
                Can someone please help me out with using XML spy for this purpose?
0
aman0711
Asked:
aman0711
  • 14
  • 12
  • 5
  • +1
6 Solutions
 
CEHJCommented:
Can you post the DTD?
0
 
aman0711Author Commented:
hi CEHJ,
 
                 Here is the DTD

< ! ELEMENT T1   ( T1D?  ,  T1E?  )  >
< ! ELEMENT_T1D  ( AG1+  , S1+ ,  P1*  )  >
< ! ATTLIST T1E  ag_id   CDATA #REQUIRED  >  recommended 
< ! ELEMENT AG1  EMPTY >
< ! ATTLIST AG1    a_id        CDATA   #REQUIRED  >  required ag1 meta table
< ! ATTLIST AG1    des     CDATA   #REQUIRED  >  recommended, ag1 meta table
< ! ATTLIST AG1    weight    CDATA   #REQUIRED  >  note  deprecated field
< ! ATTLIST AG1   id    CDATA   #REQUIRED  >  recommended, ag1 meta table
< ! ATTLIST AG1   net     CDATA   #REQUIRED  >  recommended, ag1 meta table
< ! ATTLIST AG1   ins    CDATA   #REQUIRED   >  required ag1 meta table
< ! ATTLIST AG1   loc    CDATA   #IMPLIED  >  recommended, ag1 meta table
 
 
< ! ELEMENT P1  EMPTY  >
< ! ATTLIST P1   pr_id   CDATA   #REQUIRED  >  recommended, p1 meta data
< ! ATTLIST P1   pr_name   CDATA   #REQUIRED  >  recommended, p1 meta data
< ! ATTLIST P1   a_type   CDATA   #REQUIRED  >  recommended, p1 meta data
< ! ATTLIST P1   a_sub_type   CDATA   #REQUIRED  >  recommended, p1 meta data
 
 
< ! ATTLIST S1  ( PAGE_META_DATA+ )  >  recommended, p1 meta data
< ! ATTLIST S1  s_id   CDATA  #REQUIRED  > 
< ! ATTLIST S1  s_alias   CDATA  #REQUIRED  > required m1 meta table
< ! ATTLIST S1  count   CDATA  #REQUIRED  > recommended m1 meta table
< ! ATTLIST S1  sub   CDATA  #REQUIRED  > recommended,  m1 meta table
 
< ! ELEMENT PA1  EMPTY  >
< ! ATTLIST PA1   seq          CDATA  #REQUIRED  > recommended,  m1 meta table
< ! ATTLIST PA1   page_num        CDATA  #REQUIRED  > recommended,  m1 meta table

Open in new window

0
 
aman0711Author Commented:
Everytime i try to convert this using XML spy,

   its giving me errors like "_" not expected
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
CEHJCommented:
And it could be useful to post an actual instance of an xml file
0
 
aman0711Author Commented:
Here it is CEHj

<_DATA_>
     <T1 agreement_id="99999">
          <AG1 aid="1" in_id="3" plc="ccc" des="Dummy" reg="abcd" ip="121.0.0.1" net="xyz" weight="1" city="loren" />
          <S1A s_id="5" short="Some string" pages="2" service="DUM">
                <P1 page_alias="Some String1" page_seq="1" />
                <P1 page_alias="Some String2" page_seq="2" /> 
          </S1>
          <P1A type="95" name="Some string" acctype="String" der="String" _id="33333" /> 
     </DATA>
 
     <_T1>
          <T1 ag1="4" slot="5" datetime="2020-NOV-17 " target="1" aginst="4" profile="0">
              <TX1 de_m="53" element="4" tr_level="0" estimate="32" errors="1" user="3" resp="733" /> 
              <TX2 page_seq="1">
                  <TX2_P1 de_m="338" connect="2" first="32" ser="949" remain="20" first="107" system="0" request="0" look="1" start="0" estimate="442" /> 
                  <TX_P2 element="53" page="23233" /> 
                  <TX_P3 content="0" /> 
                  <TX_P4 page="1">
                       <TX_P4_1 record="1">
                            <TX_P4_1 first="170" system="0" connect="2" delta="0" del="1" element_delta="132" remain="20" />
                            <TX_P4_1 id="6133" element="0" request="332" text="http://www.samplename.com" content="51" header="1187" address="121.0.0.1" object="/acc/" content_bytes="4000" /> 
                            <TX_P4_1 status="200" /> 
                       </TX_P4_1>
                  </TX_P4>
              </TX2>
           </T1>
     </_T1>

Open in new window

0
 
aman0711Author Commented:
Please ignore the tag <DP_TXN_MEASUREMENTS> for now. I havent put that in DTD yet

0
 
CEHJCommented:
OK. Please don't post it until the dtd validates together with the xml
0
 
aman0711Author Commented:
Hmm... Ok , I will post the complete DTD
0
 
CEHJCommented:
Yes, only when it validates with xml
0
 
aman0711Author Commented:
CEHJ, is there a technique to validate it with the XML?
0
 
CEHJCommented:
Just parse it in Java and set validation to true. There's absolutely no point in trying to generate a schema until you've got a valid dtd
0
 
CEHJCommented:
You should be able to do that in XMLSpy too
0
 
aman0711Author Commented:
ok CEHJ... I am trying with XML spy... Actually trying to get DTD and SChema from the XML file iteself.
but the file size is 160mb and XMLspy is running out of memory
0
 
CEHJCommented:
>>Actually trying to get DTD and SChema from the XML file iteself.

That will only work of course, if a valid DTD can be inferred, so the xml has already to be correct. So far, i haven't seen anything posted that looks correct
0
 
aman0711Author Commented:
>> so the xml has already to be correct

XML is correct... Actually I am trying to load the Actual XML file in XML spy
0
 
CEHJCommented:
>>XML is correct...

OK. You could attach that as a file in that case
0
 
aman0711Author Commented:
CEHJ, can i instead email you to your personal email?
? coz its proprietary
0
 
CEHJCommented:
OK. It's in my profile
0
 
aman0711Author Commented:
Did you get it CEHJ?
0
 
objectsCommented:
What are you using xmlbeans exactly. And why use a dtd?

0
 
aman0711Author Commented:
lol to get that table built out of that XML file.

Objects can i send you the XML file , along with table that we are expecting out of that. At least the requirement will clear up then?
I already sent the file to CEHJ as well, but I guess he is not online anymore
0
 
objectsCommented:
far better technologies for that these days, xmlbeans is a bit dated and only really suited to limited applications. We stopped using it years ago.
For example xml that you already have a valid xsd for
0
 
aman0711Author Commented:
I am really confused here... what to do and what not to do :-(

Can you have a look at my XML then suggest your best possible way?
0
 
objectsCommented:
I already have, I'm a bit confused why you changed approachs when you were close to have it finished.

0
 
aman0711Author Commented:
yeah that time I had it coded quite... ok m gonna start again with that code and request you for your help...
and will try to generate the DTD and schema too..
wow.. I am so Lost :)
0
 
CEHJCommented:
>>I already sent the file to CEHJ as well, but I guess he is not online anymore

I am now. My isp rejected the file. I sent you another address to try
0
 
objectsCommented:
and you probably won't be able to generate a schema anyway (not one that any use), you need to write the schema yourself to get anything decent.

0
 
CEHJCommented:
There's no need to get lost. And there's no need to write much code either - most xml->bean mapping technologies will do it for you
0
 
aman0711Author Commented:
I sent the file to your new email again CEHJ.

I take both of you as my teachers.... please somehow get me out of this trouble :)
0
 
objectsCommented:
I suspect CEHJ has never actually used xmlbeans :)

0
 
CEHJCommented:
:-)
0
 
ModernMattCommented:
Data replaced per member request.

ModernMatt
EE Moderator
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 14
  • 12
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now