[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Generic Lookup (Element Mapping)

Subject: Generic Lookup (Element Mapping)
From: "Faroukh Fekravar" <fekravar@xxxxxxxxxxxxxxxxxx>
Date: Tue, 7 May 2002 08:15:43 -0500
generic lookup table
Hi everyone,

I have been trying to write a generic xslt template to map the element names
based on a lookup table.
The lookup xml file has always a subset of the elements and therefore I do
not want to hard code the element names.
The output file is a flat xml file in opposite to the input file.

I have done the part of the key (or at least I think) like

<xsl:variable name="xmlMap" select="document('Lookup.xml')"/>
<xsl:key name="lookup" match="Maps/Map"
use="concat(generate-id(),':',SEname,':',SAname,':',TEname)"/>

But my main problem is how navigate through the input file in a generic
approach.
I'm also just a little concern about the overall performance because the
input file might be MBs big.

I would appreciate any help,

Thanks,
Faroukh

----------------------------
data.xml (input)
<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>

	<aa1>
	<!-- .............. -->
	</aa1>
</project>

Lookup.xml (It contains the names of the element in the input file and the
matching names in the output)
<Maps>
	<Map>						<!-- combination of SEName, SAname and TEname is unique through
the file.
		<SEname>aa1</SEname>		<!--  element name in the input file
		<SAname>aa11</SAname>		<!-- element name in the input file, it's always
the child element of SEName
		<TEname>aa_1</TEname>		<!-- element name in output
		<TAname>aa_11</TAname>		<!-- element nemae in output, it should be the
child element of TEname
	</Map>
	<Map>
		<SEname>aa1</SEname>
		<SAname>aa12</SAname>
		<TEname>aa_1</TEname>
		<TAname>aa_12</TAname>
	</Map>
	<Map>
		<SEname>aa1</SEname>
		<SAname>aa13</SAname>
		<TEname>aa_1A</TEname>
		<TAname>aa_13</TAname>
	</Map>
	<Map>
		<SEname>aa2</SEname>
		<SAname>aa21</SAname>
		<TEname>aa_2</TEname>
		<TAname>aa_21</TAname>
	</Map>
<!-- no mapping for aa22 -->
	<Map>
		<SEname>aa3</SEname>
		<SAname>aa31</SAname>
		<TEname>aa_3</TEname>
		<TAname>aa_31</TAname>
	</Map>
</Maps>

The output should look like:
<project>
	<aa_1>
		<aa_11>aa11_value</aa_11>
		<aa_12>aa12_value</aa_12>
	</aa_1>
	<aa_1A>		<!-- Elelment aa_1 in the source has been mapped to two elements
(aa_1 and aa_1A) in the target-->
		<aa_13>aa11_value</aa_13>
	</aa_1A>
	<aa_2>
		<aa_2>aa21_value</aa_2>
	</aa_2>
	<aa_3>
		<aa_3>a31_value</aa_3>
	</aa_3>
	<aa_1>
		<!-- ................. -->
	</aa_1>
</project>




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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.