Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT 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 April 20th, 2007, 05:46 AM
Authorized User
 
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mapping of elements from 2 different Namespaces

I have a query regarding mapping of 2 different namespace elements :

1).I get the undermentioned XML data from a 3rd party system:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<FIXML xmlns="http://www.fixprotocol.org/FIXML-4-4">
    <Order Acct="1" ExDest="ExchDest">
        <Hdr Snt="2007-04-05T13:34:47"/>
        <Instrmt Issr="Barclays" MMY="200903"/>
    </Order>
</FIXML>
2).The above XML element values need to be extracted and put in the format that we are currently using below with prefix 'i:'
Code:
<i:Interest xsi:schemaLocation="http://www.abc.com/interests:i http://abc/schemas/interests/interests.xsd" xsi:type="i:vanilla" xmlns:i="http://www.abc.com/interests:i" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:common="http://www.abc.com/common" xmlns:strategies="http://www.abc.com/strategies">
    <i:ID>249403</i:ID>
    <i:Generation>2</i:Generation>
    <i:Entered Formatted="" Format="dd mmm yyyy hh:mm:ss">2007-04-02T18:34:43</i:Entered>
    <i:Updated Formatted="" Format="dd mmm yyyy hh:mm:ss">2007-04-02T18:36:47</i:Updated>
    <i:Description>EQ.D</i:Description>
3) I have written my XSL as follows:

Code:
<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     xmlns:fo="http://www.w3.org/1999/XSL/Format" 
     xmlns:fix="http://www.fixprotocol.org/FIXML-4-4"  
     xmlns:i="http://www.abc,com/common/interests:i"
     exclude-result-prefixes="fo i ">

<xsl:template match="fix:FIXML">
   <xsl:apply-templates select="fix:Order"/>
</xsl:template>

<xsl:template match="fix:Order">

<OrderCancelRequest>
<i:ID>
<xsl:value-of select="@Acct"/>
</i:ID>
</OrderCancelRequest>
My Query is:

a) Do I need any mapping mechanism to read data from the XML defined in (1) in the format defined in (2).
   If so,please can you suggest a way for this?

b) OR is it a wise idea to hardcode the elements with the prefix of 'i:' in my style sheet as I have done
   in step (3)

Please can you advise.








 
Old April 20th, 2007, 07:34 AM
Authorized User
 
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please ignore my question.
Thanks,







Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Target Elements with Namespaces alapati.sasi XSLT 1 April 11th, 2007 05:31 AM
Namespaces Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 27th, 2006 05:19 PM
namespaces anchal C# 1 July 3rd, 2006 02:53 PM
Problems with namespaces (I think) hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 19th, 2005 02:05 AM
NAMESPACES - WHAT ARE THEY? p_nut33 C# 2 July 31st, 2003 03:18 AM





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