Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic anybody into XML? (Read 3533 times)
Administrator
Forum Administrator
*****
Offline


Yummm

Posts: 7
Location: Modders Rile
Joined: Oct 7th, 2014
Gender: Male
anybody into XML?
Apr 7th, 2002 at 9:19pm
Print Post  
I've got a question about those stupid Element Type Declarations. Let's say I've got an element looking like

Code
Select All
<someelement>
  <html><bod>this is a test φδόΔάΦ</body></html>
</someelement> 



Now I want that this element to have the value '<html><bod>this is a test φδόΔάΦ</body></html>' and not any subnotes. Using
Code
Select All
<!ELEMENT someelement (#PCDATA)> 

doesn't work because he interprets those <>. But I don't want him to do so. Also replacing those chars by &lt; and &rt; is not an option! I want him so assign the whole string to this element, with all its special chars and stuff. Is there any Element Content Type which would do the job?
  

The Administrator.
Back to top
WWW  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: anybody into XML?
Reply #1 - Apr 7th, 2002 at 9:32pm
Print Post  
Use type CDATA if you're not going to have any subelements.
PCDATA = Parsed Character Data, parsed by the parser.
CDATA = Character Data, NOT parsed by the parser.

Might want to use a schema, because in that you have to specify which elements are complex (contain other elements).
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
Administrator
Forum Administrator
*****
Offline


Yummm

Posts: 7
Location: Modders Rile
Joined: Oct 7th, 2014
Gender: Male
Re: anybody into XML?
Reply #2 - Apr 7th, 2002 at 9:42pm
Print Post  
How would I have to use this CDATA typ? I already tried
Code
Select All
<!ELEMENT someelement (#CDATA)> 


as a schema but it gave me an error Undecided
  

The Administrator.
Back to top
WWW  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: anybody into XML?
Reply #3 - Apr 7th, 2002 at 10:42pm
Print Post  
Ah forget it, just leave it as PCDATA and define a CDATA section in the content, like so:

Code
Select All
<![CDATA[
blah blah
]]>
 

  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
Administrator
Forum Administrator
*****
Offline


Yummm

Posts: 7
Location: Modders Rile
Joined: Oct 7th, 2014
Gender: Male
Re: anybody into XML?
Reply #4 - Apr 7th, 2002 at 10:55pm
Print Post  
oh ok so it's a DTD where we're talking about Roll Eyes

Here is the DTD
Code
Select All
<!ELEMENT main (first, second)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT second CDATA> 



And here the .xml file
Code
Select All
<?xml version="1.0"?>
<!DOCTYPE main SYSTEM "test.dtd">
<main>
  <first>Something in here</first>
  <second>
    <html>Just another line</html>lalala
  </second>
</main> 



Now I try that in the Delphi 6 XML-Mapper and it gives me an error about an invalid DTD. Some thing when I use (#CDATA) instead.
  

The Administrator.
Back to top
WWW  
IP Logged
 
Administrator
Forum Administrator
*****
Offline


Yummm

Posts: 7
Location: Modders Rile
Joined: Oct 7th, 2014
Gender: Male
Re: anybody into XML?
Reply #5 - Apr 7th, 2002 at 10:59pm
Print Post  
Quote:
ah forget it, just leave it as PCDATA and define a CDATA section in the content
hm ok I'll try that. Just wondering if there isn't a better way to do that e.g. by a special element typ since always adding this stuff in front looks pretty stupid...
  

The Administrator.
Back to top
WWW  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: anybody into XML?
Reply #6 - Apr 7th, 2002 at 11:52pm
Print Post  
I thought it should work with CDATA in the DTD, but... * Michael shrugs

Quote:
oh ok so it's a DTD where we're talking about Roll Eyes

That stuff you're using is from a DTD and then you said you used it in a schema. There IS a big difference, because that stuff doesn't work in a schema!

If you want to do it a better way, use a schema instead of a DTD, because unless you specify <xs:complexType> within an element, it is considered to be a simple element by default, I believe. See here.
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
Administrator
Forum Administrator
*****
Offline


Yummm

Posts: 7
Location: Modders Rile
Joined: Oct 7th, 2014
Gender: Male
Re: anybody into XML?
Reply #7 - Apr 8th, 2002 at 4:22pm
Print Post  
Hm didn't know about this XSD stuff. Anyway I tried that and even the CDATA thing but both didn't work either. Undecided

I thought XML would have been designed to be used as an universal dataformat but right now it looks to me like it is absolutly unusable for custom nontext data Sad
  

The Administrator.
Back to top
WWW  
IP Logged
 
Michael
God Member
*****
Offline


Recursion \Re*cur"sion\,
n. - See recursion.

Posts: 1003
Joined: Oct 23rd, 2001
Gender: Male
Re: anybody into XML?
Reply #8 - Apr 8th, 2002 at 9:48pm
Print Post  
Well, the standard itself is great, it's just (as with most things, such as HTML) the implementation (or lack thereof) that causes development nightmares. Is there any documentation for Delphi's XML parser? You might try looking through that for information on limitations. Either that or start searching for an alternative parser. Undecided
  

~ Michael ~
-------------
The MikeCam
A truly wise man never plays leapfrog with a unicorn.
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint