...

View Full Version : Putting an image source in XML



thesaint
10-22-2008, 08:35 AM
Hi all,

I'm new to XML so I hope you guys can bear with me if the questions are simple.

I'm trying to put in an image source in XML-DTD. Below are the codings that I have input(I have simplified the codes to my error instead of putting the whole chunk in). But when I tried validating at http://validator.w3.org/check I'm getting errors.

I know that when I input <img src> it is an xhtml, however that is not what I want. I only want it kept within XML-DTD.

Please advise or can someone illustrate via another example?



<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE information [

<!ELEMENT information (biography+, jobtype)>

<!ELEMENT biography (images)>
<!ELEMENT images (#PCDATA)>
<!ATTLIST images img src CDATA #REQUIRED>
...

]>

<information>
<biography>
<images src>
<img src="pictures/doctor/doctor4.jpg" />
</images src>

.....
</biography>


</information>

oesxyl
10-22-2008, 12:49 PM
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE information [
<!ELEMENT information (biography+, jobtype)>
<!ELEMENT biography (images)>
<!ELEMENT images (#PCDATA)>
<!ATTLIST images img src CDATA #REQUIRED>
...

]>

<information>
<biography>
<images src>
<img src="pictures/doctor/doctor4.jpg" />
</images src>

.....
</biography>


</information>

- dots could be a cause, but I guess you don't have this in the source you try to validate. You can't have text between tags something like:


<element1>
</element1>
text here is invalid
<element2>
</element2>

- src if is attribute must be src="something" or if you want to express that is about image source you can use a proper tag name like <image-source> or something else.

This is as far I test it valid, but you must change some multiplicators, must be probably biography+ instead of biography and so on.


<?xml encoding="UTF-8"?>
<!DOCTYPE information [
<!ELEMENT information (biography)>
<!ATTLIST information
xmlns CDATA #FIXED ''>

<!ELEMENT biography (images)>
<!ATTLIST biography
xmlns CDATA #FIXED ''>

<!ELEMENT images (img)>
<!ATTLIST images
xmlns CDATA #FIXED ''>

<!ELEMENT img EMPTY>
<!ATTLIST img
xmlns CDATA #FIXED ''
src CDATA #REQUIRED>
]>
<information>
<biography>
<images>
<img src="pictures/doctor/doctor4.jpg" />
</images>
</biography>
</information>


best regards

thesaint
10-22-2008, 01:13 PM
oesxyl, I manage edit to fit my scenario and validate it.

Appreciate the help.

oesxyl
10-22-2008, 01:26 PM
oesxyl, I manage edit to fit my scenario and validate it.

Appreciate the help.
I'm glad you solve it. :)
A better solution is to design schema for your xml using relax ng.

http://www.relaxng.org/

then you can convert using for example trang to what you need, dtd or else.
relax ng help a lot with validation so you can validate against a rnc or rng schema instead of dtd.

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum