Advertisement

02.15.2008 at 10:46AM PST, ID: 23166880
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Extracting images from XML file using XSLT

Tags: XSLT and XML, Firefox 2, IE 7
Hi,

I have a very simple XML file (experimental) that contains references to other XML files and I apply an XSLT script to it to extract the information out of those files.

for example, in my XML file I have this node <chunk>Al-Intro </chunk>

then the XSLT will extract the text contained in the Al-Intro.xml file  (which has an element called <text> in it) as follows:



          <xsl:for-each select="chunk">
                   
            <xsl:variable name="container"><xsl:value-of select="."/></xsl:variable>
                                             
            <xsl:variable name="file" select="concat($container,'.xml')"/>
                                       
            <xsl:apply-templates select="document($file)//text"/>

And it works perfectly.

But now I have another element in the same file (<media>) where it has attributes that defines a picture for example.

I have tried to modify my code to extract the media content the same way, but it isn't working. I'm not sure why since I'm have asleep after a long day ;)

Plz could some XSLT expert have a look at it?

Thanks a lot,

MZM

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
XML file:
 
<?xml version="1.0" encoding="UTF-8"?>
<ChunksList>
<chunk>AL-Intro</chunk>
<chunk>AL-Types</chunk>
<chunk>AL-AP1</chunk>
<chunk>AL-ANS1</chunk>
</ChunksList>
-----------------------------------------------------------------
XSLT file:
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" media-type="text" omit-xml-declaration="yes"/>
        
<xsl:template match="ChunksList">
<Lesson>
<xsl:for-each select="chunk">
<xsl:variable name="container"><xsl:value-of select="."/></xsl:variable>
<xsl:variable name="file" select="concat($container,'.xml')"/>
<xsl:apply-templates select="document($file)//text"/>
 
<!-- until this point everything is working for text element see XML file below-->
			 
<!--for selecting medis: especially image with chunks-->
<xsl:apply-templates select="document($file)//media[@type='gif'] | media[@type='jpg'] | media[@type='GIF'] | media[@type='JPG'] "><xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
<!-- $fname contains name of img attribute -->
<xsl:variable name="fname">
<!-- Convert 'cd345.gif' into 'CD345.GIF' -   -->
<xsl:value-of select="translate(@src, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:variable>
<img>
<xsl:attribute name="src"><xsl:value-of select="$fname"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="@alt"/></xsl:attribute>
</img>
<br/>
</xsl:apply-templates>
 
</xsl:for-each>
</Lesson>
</xsl:template>
</xsl:stylesheet>
 
----------------------------------------------------------------------
 
AL-Intro.xml
 
<?xml version="1.0" encoding="utf-8"?>
 
<chunk type="text" name="AL-Intro"  title="Introduction">
	<versionlist>
		<version date="2007-09-10">
			
		</version>
	 </versionlist>
 
       <media type="jpg" title="test" name="germany" src="hannover_rathaus.jpg" caption="test" align="center" copyright="mzm">
	</media>
 
	<text>
		<p>Adaptive Hypermedia is an alternative to traditional hypermedia systems and aims to overcome these two problems by providing some help and guidance to the users. An adaptive Hypermedia System aims to provide a solution to the problem of disorientation and need to accommodate varied users by being capable of searching for and filtering out the information most relevant to the user's needs, goals and interests .</p>
		<p>Adaptive educational hypermedia: counterbalance lack of interpersonal interaction in distance learning - self driven learning as they can act like a personal desktop teacher. .</p>
	</text>
 
 
 
 
	<keywords>
			<keyword>e-Learning</keyword>
	</keywords>
 
</chunk>
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: mzm_uk07
Solution Provided By: Gertone
Participating Experts: 2
Solution Grade: A
Views: 31
Translate:
Loading Advertisement...
02.15.2008 at 11:06AM PST, ID: 20904868

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.18.2008 at 08:18AM PST, ID: 20921113

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2008 at 06:57AM PST, ID: 20984823

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2008 at 04:42AM PST, ID: 20993444

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2008 at 05:08AM PST, ID: 20993593

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2008 at 05:42AM PST, ID: 20993821

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.03.2008 at 06:32AM PST, ID: 21031733

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628