|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hoi,
I have a little problem in sending the merged XML data to the file adds.xsl. The idea is to have different adds on different websites, but combining them together for each website with the help of a source list. When I add <?xml-stylesheet type="text/xsl" href="merge.xsl"?> in the file sources.xml and open this file, I can tell that the data is merged correctly, but if I open adds.xml, only the html table appears without the data that should have been merged. the newline to <br /> translater works also fine. Any help would be appreciated :) Greets, Kris file sources.xml <?xml version="1.0" encoding="ISO-8859-1"?> <files> <file>adds1.xml</file> <file>adds2.xml</file> </files> file adds1.xml <?xml version="1.0" encoding="ISO-8859-1"?> <adds> <add> <nickname>Ellen</nickname> <country>Belgium</country> <city>Antwerp</city> <birthday>06-04-1982</birthday> <email>ellen@nomail.be</email> <introduction>hoi, ik zoek een leuke jongen</introduction> <looksfor>description goes here</looksfor> <gender>V</gender> <url>www.ellen.be</url> </add> </adds> file adds2.xml <?xml version="1.0" encoding="ISO-8859-1"?> <adds> <add> <nickname>Kris</nickname> <country>Belgium</country> <city>Kapellen</city> <birthday>25-04-1979</birthday> <email>kris@nomail.com</email> <introduction>this is my personal discription</introduction> <looksfor>i am looking for someone nice</looksfor> <gender>m</gender> <url>users.pandora.be/ellen</url> </add> </adds> file merge.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/> <xsl:template match="/"> <adds_merged> <xsl:for-each select="document('sources.xml')/files/file"> <xsl:variable name="file" select="document(text())"/> <xsl:copy-of select="$file/adds/child::*"/> </xsl:for-each> </adds_merged> </xsl:template> <xsl:variable name="x" select="document('')" /> </xsl:stylesheet> adds.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:include href ="merge.xsl" /> <xsl:template match="/"> <html> <body bgcolor="white"> <h2>Mijn zoekertjes</h2> <table border="1"> <tr> <th>Nicknaam</th> <th>E-mail</th> <th>Voorstelling</th> <th>Geboortedatum</th> <th>M/V</th> <th>Geaardheid</th> <th>Url</th> </tr> <xsl:for-each select="$x/adds_merged/add"> <tr> <td> <xsl:value-of select="nicknaam"/> </td> <td> <a target="_top"> <xsl:attribute name="HREF">mailto:<xsl:value-of select="email"/></xsl:attribute> <xsl:value-of select="email"/> <foo xml:space="preserve"> </foo> </a> </td> <td> <xsl:variable name="StringIn"> <xsl:value-of select="introduction"/> </xsl:variable> <xsl:variable name="ResultTreeFragmentOut"> <xsl:call-template name="nl2br"> <xsl:with-param name="StringToTransform" select="$StringIn" /> </xsl:call-template> </xsl:variable> <xsl:copy-of select="$ResultTreeFragmentOut" /> </td> <td> <xsl:value-of select="birthday"/> </td> <td> <xsl:value-of select="gender"/> </td> <td> <xsl:value-of select="sexualinclination"/> </td> <td> <a target="_top"> <xsl:attribute name="HREF">http://<xsl:value-of select="url"/></xsl:attribute> <xsl:value-of select="url"/> <foo xml:space="preserve"> </foo> </a> </td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> <!-- template that "translates newlines to <br/> tags" --> <xsl:template name="nl2br"> <xsl:param name="StringToTransform"/> <xsl:choose> <!-- string contains newline --> <xsl:when test="contains($StringToTransform,' ')"> <xsl:value-of select="substring-before($StringToTransform,' ')"/> <br/> <xsl:call-template name="nl2br"> <xsl:with-param name="StringToTransform"> <xsl:value-of select="substring-after($StringToTransform,' ')"/> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$StringToTransform"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> adds.xml <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="adds.xsl"?> <foo></foo> |
|
#2
|
|||
|
|||
|
problem solved
Hoi,
Found a very good solution to merge different xml files for my problem. just use the following: <xsl:for-each select="document(files/file[/])/adds/add"> the file adds.xml and adds.xsl dissapeared, and everything went into the file sources.xsl this works even in IE5 Greetings, Kris |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Problem sending merged xml data from one xsl file to another |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|