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

RE: Problem with getting values from two files

Subject: RE: Problem with getting values from two files
From: Jarno.Elovirta@xxxxxxxxx
Date: Fri, 3 May 2002 09:27:38 +0300
xsl copy of two files
Heppa,

> Is is possible by XSLT
> 
> File A.
> 
> <Name value="Johan"/>
> <Address Value="JohanCompositAddress" Type="CompositeAddress"/>

document() function can only be used to retrieve well-formed XML documents and your File A is not well-formed. If you add a wrapper element, either by changing the file or using a wrapper XML document where you include the File A using external general entity, then it will work.

> File B.
> 
> <CompositeAddress>
> <JohanCompositeAddress>
> <Address Value ="NewYork"/>
> <Address Value ="Paris"/>
> </JohanCompositeAddress>
> </CompositeAddress>
> 
> Resultant File.
> <UserName Value="Johan"/>
> <UserAddres>
> <Address Value="NewYork"/>
> <Address Value="Paris"/>
> </UserAddres>
> 
> Here I want to get the result by the Single XSL file...What 
> I'm supposing
> ..the required XSL should do is
> 1. Check the type attribute of Address node of File A.
> 2. If it is CompositeAddress..then it should take the value (ie
> JohanCompositAddress) attribute of the address node of File A 
> and check it
> ...whether it is present in File B. "JohanCompositAddress"
> 3. And if it is present in file B then fetch out all the 
> address against
> <JohanCompositeAddres> and show it in the resultant file.

If you wrap the File A into some element and fix files so that the "JohanCompositeAddress" string is the same in both files, then e.g.

  <xsl:variable name="value" select="document('File A.')//Address[@Type = 'CompositeAddress']" />
  <xsl:for-each select="document('File B.')/CompositeAddress/*[name() = $value/@Value]">
    <UserName Value="{$value/preceding-sibling::Name[1]/@value}"/>
    <UserAddres>
      <xsl:copy-of select="Address" />
    </UserAddres>
  </xsl:for-each>

The node $value is bound to and the node-set the xsl:for-each selects might not be the best possible, change them to better suit the whole structure of your source document. Also, the next time you ask a question on the list, it might be worth it posting your non-functioning XSLT stylesheet and ask how to fix it, instead of asking for a whole solution.

Cheers,

Santtu

 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.