Jump to content
xisto Community
Sign in to follow this  
mimi_m

Images In XML - Help?

Recommended Posts

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

 

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! :D

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Maybe I didn't really make myself clear :)

 

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 :)

 

------------------------------------ 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... :) ) ... 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 :) )

 

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. :P

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites
Thank YouImages In XML - Help?

Replying to mimi_m Thanks for your help! I had to do the same thing for an assignment in Intro to XML (CSIS 115b in the California State School System). I was required to supply the DTD so I appreciate your thoroughness. I bet a lot of XML students in the future come across your post.

-reply by SirGuff

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.