This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange Template Behavior


Hi,

I just try to flat the structure of the xml file below:
(I know there are better ways to do that, but I'm interested in knowing why
the approach below does not work)

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="D:\finder\dims\mm.xsl"?>
<project>
	<aa1>
		<aa11>aa11_value</aa11>
		<aa12>aa12_value</aa12>
		<aa13>aa13_value</aa13>
		<aa2>
			<aa21>aa21_value</aa21>
			<aa22>aa22_value</aa22>
			<aa3>
				<aa31>aa31_value</aa31>
				<aa4>
					<aa41>aa41_value</aa41>
				</aa4>
			</aa3>
		</aa2>
	</aa1>
</project>

by using

<?xml version="1.0" encoding="utf-8"?>
<xslo:stylesheet xmlns:xslo="http://www.w3.org/1999/XSL/Transform";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
	<xslo:output indent="yes"/>
	<xslo:template match="/project">
		<project>
			<xslo:apply-templates/>
		</project>
	</xslo:template>
	<xslo:template match="*"/>
	<xslo:template match='text()'/>
	<xslo:template match="aa1">
		<xslo:element name="aa_1">
			<xslo:apply-templates mode="mapping"/>
		</xslo:element>
			<xslo:apply-templates/>
	</xslo:template>
	<xslo:template match="aa1/aa11" mode="mapping">
		<xslo:element name="aa_11">
			<xslo:value-of select="."/>
		</xslo:element>
	</xslo:template>
	<xslo:template match="aa1/aa12" mode="mapping">
		<xslo:element name="aa_12">
			<xslo:value-of select="."/>
		</xslo:element>
	</xslo:template>
	<xslo:template match="aa1/aa13" mode="mapping">
		<xslo:element name="aa_13">
			<xslo:value-of select="."/>
		</xslo:element>
			<xslo:apply-templates/>
	</xslo:template>
	<xslo:template match="aa2">
		<xslo:element name="aa_2">
		<xslo:apply-templates mode="mapping1"/>
		</xslo:element>
			<xslo:apply-templates/>
	</xslo:template>
	<xslo:template match="aa2/aa21" mode="mapping1">
		<xslo:element name="aa_21">
			<xslo:value-of select="."/>
		</xslo:element>
			<xslo:apply-templates/>
	</xslo:template>
	<xslo:template match="aa3">
		<xslo:element name="aa_3">
		<xslo:apply-templates mode="mapping2"/>
		</xslo:element>
			<xslo:apply-templates/>
	</xslo:template>
	<xslo:template match="aa3/aa31" mode="mapping2">
		<xslo:element name="aa_31">
			<xslo:value-of select="."/>
		</xslo:element>
	</xslo:template>
</xslo:stylesheet>

and I get something like that

<?xml version="1.0" encoding="UTF-16"?>
<project>
	<aa_1>
		<aa_11>aa11_value</aa_11>
		<aa_12>aa12_value</aa_12>
		<aa_13>aa13_value</aa_13>aa21_valueaa22_valueaa31_valueaa41_value</aa_1>
	<aa_2>
		<aa_21>aa21_value</aa_21>aa22_valueaa31_valueaa41_value</aa_2>
	<aa_3>
		<aa_31>aa31_value</aa_31>aa41_value</aa_3>
</project>

Why at the end of each element I have all the values of it's descendants?

It should look like that
<?xml version="1.0" encoding="UTF-16"?>
<project>
	<aa_1>
		<aa_11>aa11_value</aa_11>
		<aa_12>aa12_value</aa_12>
		<aa_13>aa13_value</aa_13>
	</aa_1>
	<aa_2>
		<aa_21>aa21_value</aa_21>
	</aa_2>
	<aa_3>
		<aa_31>aa31_value</aa_31>
	</aa_3>
</project>

I appreciate any help,
Thanks,
Faroukh


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]