|
Subject: Re: [xsl] Mapping from two sources (~ inner join in DB) From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 03 Oct 2010 15:26:44 -0400 |
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?
http://docs.oasis-open.org/ubl/os-UBL-2.0/UBL-2.0.html http://docs.oasis-open.org/ubl/UBL-2.0-update.html
~/t/ftemp $ cat input1.xml
<?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>
~/t/ftemp $ cat input2.xml
<?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>
~/t/ftemp $ cat innerjoin.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:template match="/">
<xsl:variable name="input1" select="document('input1.xml')"/>
<xsl:variable name="input2" select="document('input2.xml')"/> <OrderResponse>
<!--walk each order line-->
<xsl:for-each select="$input1/Order/OrderLine">
<xsl:variable name="input1line" select="."/>
<!--change context to the other file-->
<xsl:for-each select="$input2">
<!--act only on the lines of equal line number-->
<xsl:for-each select="key('order-line-by-number',$input1line/OLN)">
<!--join the information from both files-->
<Oline>
<xsl:copy-of select="OLN"/>
<xsl:copy-of select="$input1line/Fname"/>
<xsl:copy-of select="ID"/>
</Oline>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</OrderResponse>
</xsl:template></xsl:stylesheet>
~/t/ftemp $ xslt innerjoin.xsl innerjoin.xsl
<?xml version="1.0" encoding="utf-8"?>
<OrderResponse>
<Oline>
<OLN>1</OLN>
<Fname>aa</Fname>
<ID>123</ID>
</Oline>
<Oline>
<OLN>2</OLN>
<Fname>bb</Fname>
<ID>324</ID>
</Oline>
</OrderResponse>~/t/ftemp $<?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>
-- XSLT/XQuery training: after http://XMLPrague.cz 2011-03-28/04-01 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Mapping from two sources , sudheshna iyer | Thread | Re: [xsl] Mapping from two sources , sudheshna iyer |
| Re: [xsl] Mapping from two sources , sudheshna iyer | Date | Re: [xsl] Create an end element - p, Liam R E Quin |
| Month |