Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (ajprincess):

pls help:)

OpenStudy (ajprincess):

<!ELEMENT f((a|b)*, c+,(d|e))*> how can we write this in xml document

OpenStudy (ajprincess):

@ganeshie8

ganeshie8 (ganeshie8):

not good with xml :( @e.mccormick

mathslover (mathslover):

http://www.cs.rit.edu/~ats/plcr-2003-1/html/skript-22.html will this work?

ganeshie8 (ganeshie8):

`<!ELEMENT f((a|b)*, c+,(d|e))*>` looks like a comment syntax right ?

mathslover (mathslover):

Sorry to disturb again.. but I just got one more link :P http://docs.oracle.com/cd/E16655_01/appdev.121/e17604/adx_cp_classgen.htm#ADXDK19948 I will not disturb now.. final! :P

ganeshie8 (ganeshie8):

@mathslover i can see you have used xml before :) please go ahead, help ajp...

mathslover (mathslover):

Oh yeah... Sure! :P I once made an XML code having some lists of my favourite chocolates... ! it was a year ago.. and I even forgot that :P this seems to be much easier, so, I have forgot this too! (you know, I only remember the *tough* codes.. :P ) (jokes apart - I am only good at Maths, Physics and Chemistry... I was taking CS50 course but left it, due to schools... ! Though, am good at Scratch projects! ) --------sorry---- i can't help ----

ganeshie8 (ganeshie8):

` f((a|b)*, c+,(d|e))` is this supposed to be some regular expression ?

ganeshie8 (ganeshie8):

lol @mathslover ikr... its very easy to forget these syntax things if we don't use it for a long time

mathslover (mathslover):

:-) is this called XML DTD ?

OpenStudy (ajprincess):

yup it is <f> <a></a> <c></c> <c></c> <d></d> </f>

mathslover (mathslover):

If we have : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE note SYSTEM "Note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> then XML DTD : <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]>

OpenStudy (anonymous):

ehh, xml. One of the things I don't know :(

OpenStudy (ajprincess):

ya I am okay with that. what exactly is my problem is writing this part (a|b)*

ganeshie8 (ganeshie8):

does that mean "0 or more of a or b" ?

OpenStudy (ajprincess):

yes <!ELEMENT h (f)+> <!ELEMENT f((a|b), c+,(d|e))> then xml <h> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> </h>

mathslover (mathslover):

just tell me what is <!ELEMENT..> ? is this C or C++ or is it english ( lol ) ?

mathslover (mathslover):

Declaring either/or Content Example: <!ELEMENT note (to,from,header,(message|body))> The example above declares that the "note" element must contain a "to" element, a "from" element, a "header" element, and either a "message" or a "body" element.

OpenStudy (ajprincess):

in dtd tag is referred to as element

mathslover (mathslover):

Did that help @ajprincess ^ ?

ganeshie8 (ganeshie8):

okay then you can skip both <a> and <b> elements i think

ganeshie8 (ganeshie8):

regular expression \(x*\) means 0 or more of \(x\), so based on that \((a|b)*\) can have 0 or more of <a> and <b> elements in the start.... just a guess -.-

ganeshie8 (ganeshie8):

but you cannot have both <a> and <b>

mathslover (mathslover):

So, you want to declare zero or more occurrences of parsed characted data?

mathslover (mathslover):

*character

OpenStudy (ajprincess):

ya @mathlover. thanx. but it was nt exactly what i was looking for. so it will be this <!ELEMENT h (f)+> <!ELEMENT f((a|b)*, c+,(d|e)*)> then xml <h> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <c></c> <c></c> <e></e> </f> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> </f> </h>

mathslover (mathslover):

so, that ya was for which comment ? is this for "So, you want to declare zero or more occurrences of parsed characted data? " ? Also, what r u looking for now? So that I can help u accordingly.

OpenStudy (ajprincess):

it was for does that help? your example from w3schools

mathslover (mathslover):

Oh yes..

OpenStudy (ajprincess):

i want to knw if this is right <!ELEMENT h (f)+> <!ELEMENT f((a|b)*, c+,(d|e)*)> then xml <h> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> <e></e> </f> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <c></c> <c></c> <e></e> </f> <f> <a></a> <c></c> <c></c> <d></d> </f> <f> <b></b> <c></c> <c></c> </f> </h>

mathslover (mathslover):

lemme check that... give me 2 minutes.

mathslover (mathslover):

oops no.. I need 121.9 seconds!

OpenStudy (ajprincess):

oh k.take ur own time. 1.9 more seconds? lol k

OpenStudy (ajprincess):

i checked my answer using oxygen xml editor but what i am getting is (a|b)? instead of (a|b)*. if it is ? then the tag can occur 0 or 1 time. but in my answer i have a tag more than once. so it cannot be ?.

ganeshie8 (ganeshie8):

put two elements for <a> in one entry and try

ganeshie8 (ganeshie8):

``` <f> <a></a> <a></a> <c></c> <d></d> </f> ```

OpenStudy (ajprincess):

if i do so i get this way (a+|b)

ganeshie8 (ganeshie8):

add that ^

ganeshie8 (ganeshie8):

(a|b)? = 0 or 1 of <a>, <b> (a|b)* = 0 or MORE of <a>,<b>

ganeshie8 (ganeshie8):

you can have as many <a> elements as you want in the start, including nothing.

OpenStudy (ajprincess):

u mean within the same <f> element?

ganeshie8 (ganeshie8):

yes a,b,c,d,e are children of f, right ?

OpenStudy (ajprincess):

ya. it will be this way <f> <c></c> <d></d> </f> <f> <a></a> <a></a> <c></c> <d></d> </f>

ganeshie8 (ganeshie8):

you will need 72 <f> elements i think : <a> : 0/1/2 times <b> : 0/1/2 times <c> : 1/2 times <d> : 0/1/2 times <e> : 0/1/2 times total = (3+3)*(2)*(3+3) = 72

mathslover (mathslover):

stop everyone... I'm trying.. please :P 121.989 seconds more please!

mathslover (mathslover):

@ganeshie8 / @ajprincess - can any of u send me the .xml file of the dtd code?

ganeshie8 (ganeshie8):

im just giving out my best guess - never worked that much on xml stuff >.<

ganeshie8 (ganeshie8):

i can generate the 72 elements if any of u want to check in oxygen...

mathslover (mathslover):

don't worry I'm here ... but just attach the xml file ... due to some reasons, my text document stopped working.

mathslover (mathslover):

<!ELEMENT a EMPTY > <!ELEMENT b EMPTY > <!ELEMENT c EMPTY > <!ELEMENT d EMPTY > <!ELEMENT e EMPTY > <!ELEMENT f ( a | b | c | d | e )* > <!ELEMENT h ( f+ ) > this will be the dtd code for what ajprincess posted...

mathslover (mathslover):

wow cool! i seem to be getting it now..

OpenStudy (ajprincess):

if u dnt mind can u please give it @ganeshie8

mathslover (mathslover):

yep... i asked him too! he is making it

mathslover (mathslover):

ajprincess , why dont u use xml to dtd converter? it will help u !

OpenStudy (ajprincess):

<!ELEMENT a EMPTY > <!ELEMENT b EMPTY > <!ELEMENT c EMPTY > <!ELEMENT d EMPTY > <!ELEMENT e EMPTY > <!ELEMENT f ( a | b | c | d | e )* > <!ELEMENT h ( f+ ) > if it is so a, b, c, d and e wont be present within one entry of f

mathslover (mathslover):

i agree but it is what I get when I convert the xml to dtd...

mathslover (mathslover):

<!ELEMENT h ( f+ ) > <!ELEMENT f ( a | b | c | d )* > This is what the software says for your xml code

OpenStudy (ajprincess):

ya I used oxygen xml editor. it also converts xml to dtd. this is what i got for my answer. <?xml encoding="UTF-8"?> <!ELEMENT h (f)+> <!ATTLIST h xmlns CDATA #FIXED ''> <!ELEMENT f ((a|b)?,c+,(d|e)?)> <!ATTLIST f xmlns CDATA #FIXED ''> <!ELEMENT a EMPTY> <!ATTLIST a xmlns CDATA #FIXED ''> <!ELEMENT b EMPTY> <!ATTLIST b xmlns CDATA #FIXED ''> <!ELEMENT c EMPTY> <!ATTLIST c xmlns CDATA #FIXED ''> <!ELEMENT d EMPTY> <!ATTLIST d xmlns CDATA #FIXED ''> <!ELEMENT e EMPTY> <!ATTLIST e xmlns CDATA #FIXED ''>

mathslover (mathslover):

while you want for `*` instead of `?` right?

OpenStudy (ajprincess):

ya

mathslover (mathslover):

cool :P

OpenStudy (ajprincess):

this is what i get when i convert your code @ganeshie8 <?xml encoding="UTF-8"?> <!ELEMENT h (f)+> <!ATTLIST h xmlns CDATA #FIXED ''> <!ELEMENT f ((a*|b*),c+,d*)> <!ATTLIST f xmlns CDATA #FIXED ''> <!ELEMENT a EMPTY> <!ATTLIST a xmlns CDATA #FIXED ''> <!ELEMENT b EMPTY> <!ATTLIST b xmlns CDATA #FIXED ''> <!ELEMENT c EMPTY> <!ATTLIST c xmlns CDATA #FIXED ''> <!ELEMENT d EMPTY> <!ATTLIST d xmlns CDATA #FIXED ''>

mathslover (mathslover):

yeah.. he forgot to use "e" there.. ?

mathslover (mathslover):

I don't get where else is the mistake.. everything seems fine to me in ganeshies' code.

ganeshie8 (ganeshie8):

fixed :

ganeshie8 (ganeshie8):

good catch @mathslover :)

mathslover (mathslover):

:)

OpenStudy (ajprincess):

now this is what i get when i convert <?xml encoding="UTF-8"?> <!ELEMENT h (f)+> <!ATTLIST h xmlns CDATA #FIXED ''> <!ELEMENT f ((a*|b*),c+,(d*|e*))> <!ATTLIST f xmlns CDATA #FIXED ''> <!ELEMENT a EMPTY> <!ATTLIST a xmlns CDATA #FIXED ''> <!ELEMENT b EMPTY> <!ATTLIST b xmlns CDATA #FIXED ''> <!ELEMENT c EMPTY> <!ATTLIST c xmlns CDATA #FIXED ''> <!ELEMENT d EMPTY> <!ATTLIST d xmlns CDATA #FIXED ''> <!ELEMENT e EMPTY> <!ATTLIST e xmlns CDATA #FIXED ''>

mathslover (mathslover):

it was expected...

OpenStudy (ajprincess):

yes. but what i want is this <?xml encoding="UTF-8"?> <!ELEMENT h (f)+> <!ATTLIST h xmlns CDATA #FIXED ''> <!ELEMENT f ((a|b)*,c+,(d|e)*)> <!ATTLIST f xmlns CDATA #FIXED ''> <!ELEMENT a EMPTY> <!ATTLIST a xmlns CDATA #FIXED ''> <!ELEMENT b EMPTY> <!ATTLIST b xmlns CDATA #FIXED ''> <!ELEMENT c EMPTY> <!ATTLIST c xmlns CDATA #FIXED ''> <!ELEMENT d EMPTY> <!ATTLIST d xmlns CDATA #FIXED ''> <!ELEMENT e EMPTY> <!ATTLIST e xmlns CDATA #FIXED ''>

mathslover (mathslover):

Yehaaaaaaaaaaaaaa I think, I got it.

mathslover (mathslover):

one minute .. (lol no... 61.99230 seconds)

ganeshie8 (ganeshie8):

whats the difference between `(a|b)*` and `(a*|b*)` ?

mathslover (mathslover):

thats the point ganeshie... think about the diff. in a | b and aa | bb

ganeshie8 (ganeshie8):

both look equivalent to meh (a|b)* = a*|b*

OpenStudy (ajprincess):

(a|b)* means (a|b) occurs 0 or more times (a*|b*) means a occurs 0 or more times or b occurs 0 or more times

ganeshie8 (ganeshie8):

(a*|b*) matches both `aa` and `bb`

ganeshie8 (ganeshie8):

a*|b* also matches them both ^ hmm

OpenStudy (ajprincess):

i am really confused because i got a question this way also (a*|b)*

ganeshie8 (ganeshie8):

oh

mathslover (mathslover):

hmm............. ! I got the mistake - we should read the material again..

ganeshie8 (ganeshie8):

My guess : (a|b)* matches `abaabbbbaa`

ganeshie8 (ganeshie8):

let me give u another xml file to test it...

OpenStudy (ajprincess):

k

mathslover (mathslover):

I have a bad doubt : * means, the child-name can occur 0 or more times right? then why only limit the times to 2?

OpenStudy (ajprincess):

jst for simplicity

ganeshie8 (ganeshie8):

ganeshie8 (ganeshie8):

try that ^

OpenStudy (ajprincess):

<?xml encoding="UTF-8"?> <!ELEMENT h (f)+> <!ATTLIST h xmlns CDATA #FIXED ''> <!ELEMENT f (a*,b*,c+,d*,e*)> <!ATTLIST f xmlns CDATA #FIXED ''> <!ELEMENT a EMPTY> <!ATTLIST a xmlns CDATA #FIXED ''> <!ELEMENT b EMPTY> <!ATTLIST b xmlns CDATA #FIXED ''> <!ELEMENT c EMPTY> <!ATTLIST c xmlns CDATA #FIXED ''> <!ELEMENT d EMPTY> <!ATTLIST d xmlns CDATA #FIXED ''> <!ELEMENT e EMPTY> <!ATTLIST e xmlns CDATA #FIXED ''>

mathslover (mathslover):

if we get to know what is the difference between (a*|b*) and (a|b)* then we will get our answer... !

ganeshie8 (ganeshie8):

yes

ganeshie8 (ganeshie8):

il give one more last try :)

ganeshie8 (ganeshie8):

ganeshie8 (ganeshie8):

@ajprincess please try that

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!