pls help:)
<!ELEMENT f((a|b)*, c+,(d|e))*> how can we write this in xml document
@ganeshie8
not good with xml :( @e.mccormick
`<!ELEMENT f((a|b)*, c+,(d|e))*>` looks like a comment syntax right ?
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
@mathslover i can see you have used xml before :) please go ahead, help ajp...
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 ----
` f((a|b)*, c+,(d|e))` is this supposed to be some regular expression ?
lol @mathslover ikr... its very easy to forget these syntax things if we don't use it for a long time
:-) is this called XML DTD ?
yup it is <f> <a></a> <c></c> <c></c> <d></d> </f>
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)> ]>
ehh, xml. One of the things I don't know :(
ya I am okay with that. what exactly is my problem is writing this part (a|b)*
does that mean "0 or more of a or b" ?
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>
just tell me what is <!ELEMENT..> ? is this C or C++ or is it english ( lol ) ?
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.
in dtd tag is referred to as element
Did that help @ajprincess ^ ?
okay then you can skip both <a> and <b> elements i think
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 -.-
but you cannot have both <a> and <b>
So, you want to declare zero or more occurrences of parsed characted data?
*character
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>
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.
it was for does that help? your example from w3schools
Oh yes..
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>
lemme check that... give me 2 minutes.
oops no.. I need 121.9 seconds!
oh k.take ur own time. 1.9 more seconds? lol k
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 ?.
put two elements for <a> in one entry and try
``` <f> <a></a> <a></a> <c></c> <d></d> </f> ```
if i do so i get this way (a+|b)
add that ^
(a|b)? = 0 or 1 of <a>, <b> (a|b)* = 0 or MORE of <a>,<b>
you can have as many <a> elements as you want in the start, including nothing.
u mean within the same <f> element?
yes a,b,c,d,e are children of f, right ?
ya. it will be this way <f> <c></c> <d></d> </f> <f> <a></a> <a></a> <c></c> <d></d> </f>
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
stop everyone... I'm trying.. please :P 121.989 seconds more please!
@ganeshie8 / @ajprincess - can any of u send me the .xml file of the dtd code?
im just giving out my best guess - never worked that much on xml stuff >.<
i can generate the 72 elements if any of u want to check in oxygen...
don't worry I'm here ... but just attach the xml file ... due to some reasons, my text document stopped working.
<!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...
wow cool! i seem to be getting it now..
if u dnt mind can u please give it @ganeshie8
yep... i asked him too! he is making it
ajprincess , why dont u use xml to dtd converter? it will help u !
<!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
i agree but it is what I get when I convert the xml to dtd...
<!ELEMENT h ( f+ ) > <!ELEMENT f ( a | b | c | d )* > This is what the software says for your xml code
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 ''>
while you want for `*` instead of `?` right?
ya
cool :P
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 ''>
yeah.. he forgot to use "e" there.. ?
I don't get where else is the mistake.. everything seems fine to me in ganeshies' code.
fixed :
good catch @mathslover :)
:)
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 ''>
it was expected...
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 ''>
Yehaaaaaaaaaaaaaa I think, I got it.
one minute .. (lol no... 61.99230 seconds)
whats the difference between `(a|b)*` and `(a*|b*)` ?
thats the point ganeshie... think about the diff. in a | b and aa | bb
both look equivalent to meh (a|b)* = a*|b*
(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
(a*|b*) matches both `aa` and `bb`
a*|b* also matches them both ^ hmm
i am really confused because i got a question this way also (a*|b)*
oh
hmm............. ! I got the mistake - we should read the material again..
My guess : (a|b)* matches `abaabbbbaa`
let me give u another xml file to test it...
k
I have a bad doubt : * means, the child-name can occur 0 or more times right? then why only limit the times to 2?
jst for simplicity
try that ^
<?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 ''>
if we get to know what is the difference between (a*|b*) and (a|b)* then we will get our answer... !
yes
il give one more last try :)
@ajprincess please try that
Join our real-time social learning platform and learn together with your friends!