Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Issues keeping XML formatting with xsl:copy >Thread Next - Re: Issues keeping XML formatting with xsl:copy Re: Issues keeping XML formatting with xsl:copyTo: NULL Date: 4/10/2006 5:47:00 PM
the problem with your stylesheet is here:
<!-- DIPLAY GROUPS FROM junk_1a.xml -->
<xsl:apply-templates select="sheet">
</xsl:apply-templates>
change this to :
<xsl:apply-templates select="document('junk_1a.xml')//groups">
</xsl:apply-templates>
and things should work fine.
you can completely eliminate the temaplte with match attribute "sheet".
This template is doing a deep copy of the node groups in junk_1a.xml. It is
not calling the template that matches "groups" node.
That was the problem here.
hope this helps,
swapna
<dpfollmer@y...> wrote in message
news:1144696869.435227.137590@v......
> I am new to XML/XSLT. What I am trying to do is import or "merge" two
> XML documents using XSL. I don't need to manipulate any data or nodes,
> just want to sort of "paste" a 2nd XML document within the first and
> display the results in HTML to read something like (where ranks come
> from one document and groups come from another):
>
> Rank 1
> description
> Rank 2
> description
> Group 1
> description
> Group 2
> description
>
> The problem is that my current code just reads out the contents of the
> source XML without keeping the nodes intact.
>
> <!-- junk_1.xml: Main XML Document
> *************************************************** -->
> <?xml version="1.0" encoding="iso-8859-1" ?>
> <?xml-stylesheet type="text/xsl" href="junk.xsl" ?>
>
> <sheet>
> <ranks>
> <rank name="rank 1">
> <description>1st rank</description>
> </rank>
>
> <rank name="rank 2">
> <description>2nd rank</description>
> </rank>
> </ranks>
>
> </sheet>
>
>
> <!-- junk_1a.xml Imported XML Documet
> *************************************************** -->
> <?xml version="1.0" encoding="iso-8859-1" ?>
> <groups>
> <group name="group 1">
> <description>This is the first group</description>
> </group>
>
> <group name="group 2">
> <description>This is the second group</description>
>
> </group>
>
> </groups>
>
> <!-- junk.xsl Translation Layer
> *************************************************** -->
> <?xml version='1.0'?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
>
> <xsl:template match="/">
> <!-- DIPLAY RANKS FROM junk_1.xml -->
> <xsl:apply-templates select="sheet/ranks">
> </xsl:apply-templates>
> <br/>
>
> <!-- DIPLAY GROUPS FROM junk_1a.xml -->
> <xsl:apply-templates select="sheet">
> </xsl:apply-templates>
> <br/>
> </xsl:template>
>
>
> <xsl:template match="sheet/ranks">
> <xsl:for-each select="rank">
> <b><xsl:value-of select="@name"/></b><br/>
> <i><xsl:value-of select="description"/></i>
> <br/><br/>
> </xsl:for-each> <!-- end for-each rank -->
> </xsl:template>
>
> <xsl:template match="sheet">
> <xsl:copy-of select="document('junk_1a.xml')//groups"/>
>
> </xsl:template>
>
> <xsl:template match="groups">
> <xsl:for-each select="group">
> <b><xsl:value-of select="@name"/></b><br/>
> <i><xsl:value-of select="description"/></i>
>
> <br/><br/>
> </xsl:for-each> <!-- end for-each group -->
> </xsl:template>
>
> </xsl:stylesheet>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
