xsl-list
[Top] [All Lists]

Re: [xsl] Mapping from two sources (~ inner join in DB)

2010-10-03 14:23:31
Team,

For this, I solved using two for-each loops. I am not sure whether this is 
performance efficient way of doing this.  Please suggest if there is any other 
better way to improve performance:
====

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:fn="http://www.w3.org/2005/xpath-functions";>
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:variable name="input2" 
select="document('file:///C:/temp/input2.xml')"/>
        <xsl:template match="Order">
                <OrderResponse>
                        <xsl:for-each select="OrderLine">
                                <xsl:variable name="vOln" select="OLN"/>
                                <Oline>
                                <xsl:variable name="vID">
                                        <xsl:for-each 
select="$input2/POOrder/POOrderLine">
                                                <xsl:if test="$vOln=OLN">
                                                        <xsl:value-of 
select="ID"/>                                             
                                                </xsl:if>
                                        </xsl:for-each>
                                        </xsl:variable>
                                        <OLN><xsl:value-of 
select="$vOln"/></OLN>
                                        <ID><xsl:value-of select="$vID"/></ID>
                                        <Fname><xsl:value-of 
select="Fname"/></Fname>
                                        <Email><xsl:value-of 
select="Email"/></Email>                   
                                </Oline>
                        </xsl:for-each>
                </OrderResponse>
        </xsl:template>
</xsl:stylesheet>
=====

--- On Sun, 10/3/10, sudheshna iyer <sudheshnaiyer(_at_)yahoo(_dot_)com> wrote:

From: sudheshna iyer <sudheshnaiyer(_at_)yahoo(_dot_)com>
Subject: [xsl] Mapping from two sources (~ inner join in DB)
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Sunday, October 3, 2010, 2:56 PM
Team,

For the below question, I got the answers from you using
<xsl:for-each-group>. But my version of XSLT is not
supporting xsl:for-each-group. 

Is there a different way of implementing this? 
=======
I need to have two sources:

input1 and input2. 

input1:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Order>
    <OrderLine>
           
<OLN>1</OLN>
           
<Fname>aa</Fname>
    </OrderLine>
    <OrderLine>
           
<OLN>2</OLN>
           
<Fname>bb</Fname>
    </OrderLine>    
</Order>


input2:
<?xml version="1.0" encoding="ISO-8859-1"?>
<POOrder>
    <POOrderLine>
           
<OLN>1</OLN>
           
<ID>123</ID>
           
<LName>aa</LName>
    </POOrderLine>
    <POOrderLine>
           
<OLN>2</OLN>
           
<ID>324</ID>
           
<LName>bb</LName>
    </POOrderLine>    
    <POOrderLine>
           
<OLN>3</OLN>
           
<ID>456</ID>
           
<LName>bb</LName>
    </POOrderLine>    
</POOrder>

I need the output from both sources combined. Please note
that first two elements are coming from input1 and thrid
element is from input2. What is the 
optimal way of doing this?

<?xml version="1.0" encoding="ISO-8859-1"?>
<OrderResponse>
    <Oline>
       
<OLN>1</OLN>
       
<Fname>aa</Fname>
       
<ID>123</ID>
    </Oline>
    <Oline>
       
<OLN>2</OLN>
       
<Fname>bb</Fname>
       
<ID>324</ID>
    </Oline>
</OrderResponse>


      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>