Toon posts:

[XSLT] 2 xml files combineren tot 1 html output

Pagina: 1
Acties:

Verwijderd

Topicstarter
Voor school ben ik aan een opdracht bezig en ik moet nu een XSLT sheet schrijven en die aan een XML bestand koppelen maar met die sheet moet ik tegelijkertijd ook gegevens uit een ander XML bestand kunnen halen. Ik krijg het maar niet voor elkaar om die gegevens uit het andere XML bestand te halen.

De XSLT sheet tot nu toe:
XML:
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
    <xsl:variable name="country">Malaysia</xsl:variable>
    <xsl:variable name="file" select="document('mondial-2.0.xml')" />
    <xsl:template match="/destination">
          
          <html>
            <head>
                <title><xsl:value-of select="$country"/></title>
            </head>
            <body>
                <xsl:apply-templates select="name"/>
                <xsl:apply-templates select="environment/geography"/>
                <xsl:apply-templates select="weather/overview"/>
                <xsl:apply-templates select="culture/history"/>
                
                <b>Attractions</b><br/>
                <xsl:apply-templates select="attractions/destination"/>
                                <xsl:apply-templates select="country"/>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="name">
        <div align="left"><h1><xsl:value-of select="."/></h1></div>
        <xsl:value-of select="$file/mondial/country/name"/>

    </xsl:template>
    
    <xsl:template match="environment/geography">
        <b>Geography</b>
        <div align="left"><xsl:value-of select="."/></div><br/>
    </xsl:template>
    
    <xsl:template match="weather/overview">
        <b>Weather overview</b>
        <div align="left"><xsl:value-of select="."/></div><br/>
    </xsl:template>
    
    <xsl:template match="culture/history">
        <b>History</b>
        <div align="left"><xsl:value-of select="."/></div><br/>
    </xsl:template>
    
    <xsl:template match="attractions/destination">
        <xsl:value-of select="name"/>
    <div align="left"><xsl:value-of select="general/introduction/long"/></div><br/>
    </xsl:template>
    
    <xsl:template match="country">
        <xsl:value-of select="document('mondial-2.0xml')/mondial/country[name='$country']/population"/>
    </xsl:template>

</xsl:stylesheet>

een klein gedeelte van het bestand Mondial-2.0.xml omdat het orgineel enorm groot is
XML:
1
2
3
4
5
<mondial>
    <country car_code="AL" area="28750" capital="cty-cid-cia-Albania-Tirane">
    <name>Albania</name>
    <population>3249136</population>
    <population_growth>1.34</population_growth>

Zoals te zien in merge.xsl het ik al op verschillende manieren geprobeert om gegevens uit het andere bestand op te halen maar tot nu toe is het me nog niet gelukt. Het is de bedoeling om gegevens van het land dat je als naam in een variabele hebt gezet te uit de mondial-2.0.xml te halen. Ik heb hier een heel dik boek over XML en daar kan ik nergens een echt duidelijk uitleg vinden en ook heb ik al goed gezocht op internet maar nog niet iets kunnen vinden. Ik hoop dat iemand me hier mee kan helpen. Bij voorbaat dank _/-\o_

[ Voor 21% gewijzigd door NMe op 19-06-2006 10:32 . Reden: [code]-tags toegevoegd. Doe je dat de volgende keer zelf? :) ]


  • Thomastux
  • Registratie: Februari 2004
  • Laatst online: 18-02 12:37
schandalig! UWT is echt niet zo moeilijk, reserveer er genoeg tijd voor en verspil geen tijd van de mensen hier!

  • Rigi
  • Registratie: September 2001
  • Laatst online: 30-11-2018
Thomastux schreef op maandag 19 juni 2006 @ 10:06:
schandalig! UWT is echt niet zo moeilijk, reserveer er genoeg tijd voor en verspil geen tijd van de mensen hier!
lol, het gaat om de UWT die gegeven wordt in Utrecht?

  • Thomastux
  • Registratie: Februari 2004
  • Laatst online: 18-02 12:37
Rigi schreef op maandag 19 juni 2006 @ 10:13:
[...]


lol, het gaat om de UWT die gegeven wordt in Utrecht?
yep, bij informatiekunde

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 22-01 23:51

NMe

Quia Ego Sic Dico.

Modbreak:Zeg, kunnen we het misschien ontopic (en in het geval van Thomastux: vriendelijk) houden?

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


  • Thomastux
  • Registratie: Februari 2004
  • Laatst online: 18-02 12:37
ok, kijk eens bij het tweede punt van de aanwijzingen bij de opdracht ;)

[ Voor 5% gewijzigd door Thomastux op 19-06-2006 10:48 ]


  • Dennis
  • Registratie: Februari 2001
  • Laatst online: 14:39
code:
1
        <xsl:value-of select="document('mondial-2.0xml')

mondial-2.0.xml ?

Oftewel, puntje vergeten?

[ Voor 11% gewijzigd door Dennis op 19-06-2006 22:01 ]

Pagina: 1