cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the Occurence of root element to unbounded in DTD file

GabrielSagaya
Active Contributor
0 Kudos

Hi all,

Please look into the sample DTD file where note is the root element having occurence (min=1,Max=1).

I want to change the occurence of root element as 1..unbounded.

<!DOCTYPE note [

<!ELEMENT note (to,from,heading,body)>

<!ELEMENT to (#PCDATA)>

<!ELEMENT from (#PCDATA)>

<!ELEMENT heading (#PCDATA)>

<!ELEMENT body (#PCDATA)>

]>

regards

Gabriel

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

you can change the occurance of IDOC TYPE but not MESSAGE TYPE.

for changing the occurance of IDOC TYPE, first download the XSD to file and change the occurance. and re-import as External Definition.

Former Member
0 Kudos

Normally,

You can not have root element with multiple occurence.

Which will make XML not well- formed.

For Any XML to be well-formed root element(Top level) should occur only once.

You can check on any editors like Altova XML Spy.

Hope this helps.

Best Regards,

Divyesh

Former Member
0 Kudos

With XSDs it's possible to have multiple root elements. But when searching I did not found any reference showing this for DTDs... frankly I didn't tried before for DTDs.

You may check with the Altova tool - it's the best out there. If it's impossible you either choose XSD or set a new root element on top.

GabrielSagaya
Active Contributor
0 Kudos

Hi

If your statement is true that root element(Top level) should occur only once,

then modification of the occurrence of root element to unbounded in XSD file is possible how??

Former Member
0 Kudos

Hi,

Root element serves as MT in IR.

You can not change the occurence of MT.

You can have alternate root elements but you can hev only single root element.

Yes, we do change occurence of element to unbounded, like In case of IDOC, we change occuremce of element ORDERS/IDOC element not for ORDERS element, which acts as root element of XML message.

Thanks,

Divyesh

Former Member
0 Kudos

Hi,

You can change occurence of chaild elements.

I think,About changing occurence of child elements would npt be possible.

A DTD like:

<?xml version="1.0" standalone="yes"?>

<!DOCTYPE rootelement [

<!ELEMENT rootelement (childelement+)>

<!ELEMENT childelement (#PCDATA)>

]>

Will confirm to structure:

<rootelement>

<childelement>Child element.</childelement>

<childelement>Child element.</childelement>

</rootelement>

Best Regards,

Divyesh

GabrielSagaya
Active Contributor
0 Kudos

Hi

I need the DTD structure for the following one.

<rootelement>

<childelement>Child element.</childelement>

</rootelement>

<rootelement>

<childelement>Child element.</childelement>

</rootelement>

There you can see the multiple occurence of root element. How do you change the occurrence of root element to unbounded in DTD file.

But its possible in XSD...

Former Member
0 Kudos

You can use this to express whether the element is required or optional:

<!ATTLIST elementname attr1 TYP #REQUIRED

attr2 TYP #IMPLIED

#REQUIRED => must appear

#IMPLIED => optional appearance

Or this to express it may occure min 1:

<!ELEMENT autor (name, vorname+)>

? => element may occur once or never

+ => element may occur min 1

  • => element may occure optional / as often as necessary

Edited by: Kai Lerch-Baier on Apr 14, 2009 3:28 PM

GabrielSagaya
Active Contributor
0 Kudos

Hi,

Thanks for your reply.

Its possible to change the occurence of the Childnodes as 0..1, 0..Unbounded, 1..unbounded by make use of ?,*,+.

But How do we change the occurence of the rootelement say note as 1..unbounded ?

Former Member
0 Kudos

just add this:

<!ELEMENT notelist (note)*>

Regards,

Kai

GabrielSagaya
Active Contributor
0 Kudos

Hi

Thanks for your reply.

Since note is my message type i dont want another element should act as root element.

In external Definition Note should act as Message type having occurrence 1..unbounded

Former Member
0 Kudos

Hm... this makes it a little harder ;o)

did you already tried this (not sure whether it works)?

<!ELEMENT note* (to,from,heading,body)>

As an alternative - would it be possible to use XSD instead of DTD? It's easier with XSDs!

Former Member
0 Kudos

With XSD it would look like this:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note" maxOccurs="unbounded">

<xs:complexType>

<xs:sequence>

......

Edited by: Kai Lerch-Baier on Apr 14, 2009 4:10 PM

GabrielSagaya
Active Contributor
0 Kudos

Hi

I tried with that.

When i import it in External Definition It gives an error.

Also is there any DTD to XSD Converter for this so that we can change the occurence of root element?

Former Member
0 Kudos

You may use this tool ALTOVA XML SPY (a test phase of 30 days is given). It's possible to create XSD / DTS / etc. with this tool and also to convert XSD <=> DTD or even generate a DTD on a XML basis.

http://www.altova.com/simpledownload2c.html?gclid=CKLh3o7H8JkCFYUSzAodsAzuRw

Hope this helps to resolve the problem ;o)