Nov 23, 2009

Images In XML - Help?

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > Miscellaneous Scripting Languages & Ideas

Images In XML - Help?

mimi_m
Can anyone help me out? I need to implement images into a xml webpage, and I don't know how it's done blink.gif

It's for an assignment, and I have ta do it by a .xml page and a .xsl page (for stylesheets). I'm kinda new to xml, so I just know the basics and stuff. I can't find anything on images, but I've seen it done, so does anyone wanna give me a hand with this?

any help is appreciated! biggrin.gif

Comment/Reply (w/o sign-up)

ninjamunky
I thought .xml was for formatting, and was supposed to work with .html, the visual part of the webpage. So, the way I always understood it, .xml isn't actually presented directly. You will not end up at ninja.astahost.com/index.xml I'm not sure though.

Comment/Reply (w/o sign-up)

mimi_m
Maybe I didn't really make myself clear blink.gif

What I need to do is make an XML page, but format the content using an external XSL page. So I've got all the content written down in the XML page (with the elements and dtd and all), and the main way I'm formatting it, is by using HTML in the XSL page, by using this tag to gather the content data:

<xsl:value-of select="element" />

BUT I'm not sure how to add images (or image links) as part of my content, so I can generate it with the rest of the data (by the xsl page). So that's what I need to find out. I hope that makes it a little clearer, if anyone knows what to do, I'd really appreciate a reply...

thanx biggrin.gif

------------------------------------ Merged by m^e

I'm so stoopid, the answer was infront of me the whole time... I just forgot to format the DTD properly. So silly.

Anyway, for those of you who are interested, or are like me and are missing something that you cant figure out... (and to think i spent about a week trying to search the net and find out what was wrong... tongue.gif ) ... Here is what you need to generate images with XML and XSL:

The XSL code is this:

<img>
<xsl:attribute name="src">
<xsl:value-of select="image"/>
</xsl:attribute>
</img>

Obviously. And in the XML - again obviously - you need an element that's called <image>. Eg:

<vodka name="EffenBlackCherryVodka">
<name>Effen Black Cherry Vodka</name>
<producer>Effen Vodka</producer>
<country>Netherlands</country>
<type>Black Cherry Vodka</type>
<size>750ml</size>
<abv>35% alc/vol</abv>
<image>effen_black.gif</image>
<price currency="USD">USD $30.08</price>
</vodka>

(ignore the rest, I was doing my assignment on Vodka, of all things wink.gif )

And MAKE SURE U DONT PULL A 'ME' and forget to add the image element to your DTD. Again, heres my example:

<!DOCTYPE students [
<!ELEMENT vodkas (vodka+)>
<!ELEMENT vodka (name,producer*,country,type,size*,abv*,price?,image*)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT producer (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT abv (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT image (#PCDATA)>
<!ATTLIST vodka name ID #REQUIRED>
<!ATTLIST price currency (AUD|USD|EUR) #IMPLIED>
]>

And DONE! I can't believe I forgot this part >.<

Any way, hope that helps other confused peoples. tongue.gif

 

 

 


Comment/Reply (w/o sign-up)

FirefoxRocks
I don't think that a DTD is actually necessary. DTDs are only for validating XML documents and without it, it still should function fine (except when trying to validate it).

With XSL, I inserted an image by using the method found here: http://w3schools.invisionzone.com/index.php?showtopic=16174 (that topic was also created by me)

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for images, xml
advertisement



Images In XML - Help?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com