Google Answers Logo
View Question
 
Q: Transforming multiple XML documents using XSL ... XML lookups ( No Answer,   1 Comment )
Question  
Subject: Transforming multiple XML documents using XSL ... XML lookups
Category: Computers > Programming
Asked by: subu62-ga
List Price: $5.00
Posted: 05 Apr 2004 14:13 PDT
Expires: 05 May 2004 14:13 PDT
Question ID: 325628
I am trying to extract values from two XML files that follow different schema
to make an HTML form. 

The following description is a simplified version of what I am trying to do.

The first file is like this: (first.xml)
   <Object>
      <Entry key="/a/b/c/d">
          defg
      </Entry>
      ....
    </Object>

The second XML file is like this (second.xml):
    <a>
      <b>
         <c>
            <d>
              this value is what I want
            </d>
          </c>
        </b>
      </a>

I am using Perl/LibXSLT/LibXML/XPath etc.

My XSL file works on the first file ...
    <xsl:template match="Object">
        <xsl:apply-templates select="Entry">
    <xsl:template>
    <xsl:template match="Entry">
         ....    ???? What do I use here to get the value of looking up @key  
                      in second.xml ????
     </xsl:template>

I have looked at the document() function in XSLT ... So, I could do:
       <xsl:value-of select=document('second.xml')/a/b/c/d>

However the problem is I need to "parameterize" the /a/b/c/d nodename that 
needs to be looked up. So, for example if the key attribute is /j/k/l/m
I need to look up the XPath expression /j/k/l/m in second.xml and output
this from the XSL file. All the documents I have researched on the net only
show the "hard-coded" lookups from the second file i.e. they assume that you 
know the name of the node that needs to be looked up.

How do I generalize the document()/.... so that it works for any value of @key
from first.xml ?

Anything I try using <xsl:variable> stuff and using document()/$variable 
gives me an invalid expression error.

Clarification of Question by subu62-ga on 06 Apr 2004 03:32 PDT
Regarding the comment posted:
 Once you have set a variable's value, you cannot change or modify that value!
 You can only change "parameters". However, anytime I do document(...)/$var
  I get an invalid expression error.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Transforming multiple XML documents using XSL ... XML lookups
From: samrat_barve-ga on 06 Apr 2004 01:35 PDT
 
Hi Subu ,
First of all <xsl:variable> works in IE 6.0 and NN(Netscape)6.0 .

I think u can xsl:variable easily  intially u can store some dummy
value in variable and when u get the actual nodes(i.e /a/b/c/c or
/l/m/n/o whatever)
u can store that value in variable .

two references i'm suggesting 

http://www.w3schools.com/xsl/el_variable.asp

http://msdn.microsoft.com/library/default.asp?url=/library/enus/xmlsdk30/htm/xmcongettingstartedwithxslttutorial.asp

the msdn source is very very good also ..
www.w3schools.com have  very good tutorial and examples for xslt etc etc.

Due to time shortage i couldn't give u complete solution  to ur problem.
hope u find the solution ..

Thanxs ,
Samrat.A.Barve

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy