Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Issues keeping XML formatting with xsl:copy

From: dpfollmer@-----.---
To: NULL
Date: 4/10/2006 12:21:00 PM

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>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent