Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2006, 03:27 PM
Authorized User
 
Join Date: Jan 2006
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default Joining 2 or more XML files

Suppose I have state.xml and address.xml. state.xml has the state name, abbreviation, and its capital city. address.xml has person's name, street address, city, state, zip code. When I open address.xml and go to address that has new york in state, I want to extend address.xml to reference state.xml and display the new york abbreviation and if i go to an address with new jersey, I want it is abbreviation and...so now and so now. How do I do that?
 
Old January 25th, 2006, 04:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Something like this. Use address.xml as the principal input document. Do

<xsl:variable name="addresses" select="/"/>
<xsl:variable name="states" select="document('state.xml')"/>

<xsl:template match="address">
  <address>
    <xsl:copy-of select="*"/>
    <xsl:copy-of select="$states/states/state[name=current()/state]/abbreviation"/>
  </address>
</xsl:template>

If the look-up table is large, you can use keys (xsl:key) for greater efficiency.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 25th, 2006, 08:39 AM
Authorized User
 
Join Date: Jan 2006
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cutting and joining wmv files arun.sharma.kumar Visual C++ 0 January 25th, 2007 02:35 AM
XSLT between two XML files NEO1976 XSLT 15 July 24th, 2006 08:52 AM
Problem to create an xml file from two xml files saurabh_inblore XSLT 1 April 12th, 2006 02:58 AM
Concatenating many XML files srivalli9 J2EE 0 November 12th, 2003 03:14 PM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.