473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A conversion using XSLT.

I have an Source XML called SubOrderMessage.xml which needs to be transformed

Expand|Select|Wrap|Line Numbers
  1.  
  2. Source 'SubOrderMessage.xml'
  3. ---------------------------
  4. <?xml version="1.0" encoding="UTF-8"?>
  5. <FIXML xmlns="http://www.fixprotocol.org/FIXML-4-4">
  6. <Order Acct="1" ExDest="ExchDest" ><Hdr Snt="2007-04-05T13:34:47" /><Instrmt Issr="Barclays" MMY="200903" /></Order></FIXML>
  7.  
  8.  
to be converted into:

Expand|Select|Wrap|Line Numbers
  1.  
  2. OUTPUT XML
  3. ----------
  4.  
  5. <?xml version="1.0" encoding="UTF-8" ?> 
  6. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" 
  7. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.fixprotocol.org/FIXML-4-4" 
  8. xmlns:i="http://www.ABC.com/interests:i">
  9. <xsl:output method="xml"/>
  10.  
  11. <i:ID>1</i:ID>
  12. <i:Date>2007-04-05</i:Date>
  13. <i:Issuer>Barclays</i:Issuer>
  14.  
  15.  
Even though the above elements are in namespace 'i:',I am trying the below,but am unable to get the output

My xsl is:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version="1.0" encoding="UTF-8" ?> 
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" 
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.fixprotocol.org/FIXML-4-4" 
  5. xmlns:i="http://www.ABC.com/interests:i">
  6. <xsl:output method="xml"/>
  7. <xsl:template match="/">
  8.  
  9. <i:ID><xsl:value-of select="Order@Acct" /> </i:ID>
  10.  
  11.  
  12.  
Can someone please help me out to get the above output please?
No offence meant.
Apr 16 '07 #1
3 1849
dorinbogdan
839 Expert 512MB
Something is wrong in the XML with xmlns="http://www.fixprotocol.org/FIXML-4-4"
Remove the xmlns attribute from <FIXML> element and then
<xsl:value-of select="FIXML/Order/@Acct" /> works.
Apr 16 '07 #2
Yes,thats what I had guessed and removed it off.

How do I get the value of Hdr which is an element under Oder?
Have I done the right way as below?


Expand|Select|Wrap|Line Numbers
  1.  
  2. <?xml version="1.0" encoding="UTF-8" ?> 
  3. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  4. <xsl:output method="xml"/>
  5.  
  6. <xsl:template match="FIXML">
  7. <xsl:apply-templates  select ="Order"/>
  8. <xsl:apply-templates  select ="Order/Hdr"/>
  9. </xsl:template>
  10.  
  11. <xsl:template match="Order">
  12. <ID>
  13. <xsl:value-of select="@Acct"/> 
  14. </ID>
  15. </xsl:template>
  16.  
  17. <xsl:template match="Order/Hdr">
  18. <SD>
  19. <xsl:value-of select="@Snt"/> 
  20. </SD>
  21. </xsl:template>
  22.  
  23. </xsl:stylesheet>
  24.  
Apr 16 '07 #3
dorinbogdan
839 Expert 512MB
If want to see the <ID and <SD> tags in browser, then update the code like this:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="FIXML">
  2.     <xsl:apply-templates  select ="Order"/>
  3. </xsl:template>
  4.  
  5. <xsl:template match="Order">
  6.     &lt;ID&gt;    
  7.         <xsl:value-of select="@Acct"/> 
  8.     &lt;/ID&gt;
  9.  
  10.     &lt;SD&gt;     
  11.         <xsl:value-of select="Hdr/@Snt"/> 
  12.     &lt;/SD&gt;
  13. </xsl:template>
  14.  
Apr 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: plopez | last post by:
Hi I'm a bit of a noob to xslt. I have a data.xml document like this.. input.xml <energy> ..lots and lots of other data..... <units>(Watts)<\units> <value>1000.0<\value> </energy>
3
by: jazzdman | last post by:
Hi, From what I've been reading so far, I think I already know the answer to this question, but I'll ask anyway. I have an XML document that contains cdata sections with HTML. I want to...
12
by: hawat.thufir | last post by:
I'm trying do some "screen scraping", and am using <http://www.oreilly.com/catalog/xmlhks/> for inspiration. First I'd like to convert XHTML to XML, or extract XML from XHTML, I'm not sure how...
2
by: Ryan Adler | last post by:
I have a terrible headache from this problem. Perhaps someone can help. My XML is formatted like this: <events> <event> <starts-at>123456<starts-at/> <event> ... <events/>
1
by: P | last post by:
Hi, I am finding it little harder to get this done, kindly help me. I need to convert an XML file to a JavaScript file (Array) using XSLT, 1. Can I use <xsl:output method="text">? 2. I am...
0
by: avidcoder | last post by:
HI all I am a beginner in XML space . Some one give me ideas about how to develop a """" Good GUI implementation with "xml conversion" using XSLT as backend solution""" Actually i want...
1
by: PAjay | last post by:
Dear All, I have a requirement where in i will be getting an XML and XSLT file as inputs, I need to transform the XML file using the given XSLT and should convert the transformed XML into...
2
by: sethridge1991 | last post by:
Hi Everyone, I am trying to send a XML file via SFTP staying completely in UNIX. The data in the file will vary everytime I create and send it. This is not a simple address book dump. This...
0
by: vikasthukral17 | last post by:
Hello Friends i want to convert xml shown under into excel file,xml is as <?xml version="1.0" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="AggrPositions.xsl"?> <DataOut> ...
0
by: vikasthukral17 | last post by:
Hello Friends i want to convert xml shown under into excel file,xml is as <?xml version="1.0" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="AggrPositions.xsl"?> <DataOut>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.