Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:12:33+00:00 2026-05-26T01:12:33+00:00

We are using XSL to convert a XML file into a pipe-delimited format. <?xml

  • 0

We are using XSL to convert a XML file into a pipe-delimited format.

<?xml version="1.0" encoding="UTF-8"?>
<ns:tradedata xmlns:ns="http://schemas.com/enterprise/util/extractservice/v1">
    <tradedata_item>
        <ORDER_ID>113632428</ORDER_ID>
        <CUSIP>31393FHA7</CUSIP>
        <TICKER>FHR</TICKER>
        <SEC_NAME>FHR 2527 SG</SEC_NAME>
        <ORDER_QTY>169249.6824</ORDER_QTY>
    </tradedata_item>
    <tradedata_item>
        <ORDER_ID>113632434</ORDER_ID>
        <CUSIP>31393G2C7</CUSIP>
        <TICKER>FHR</TICKER>
        <SEC_NAME>FHR 2531 ST</SEC_NAME>
        <ORDER_QTY>214673.0105</ORDER_QTY>
    </tradedata_item>
    <tradedata_item>
        <ORDER_ID>113632431</ORDER_ID>
        <CUSIP>527069AH1</CUSIP>
        <TICKER>LESL</TICKER>
        <SEC_NAME>ZZZ_LESLIE S POOLMART INC</SEC_NAME>
        <ORDER_QTY>365000.0000</ORDER_QTY>
    </tradedata_item>
</ns:tradedata>

We need the first line in the output to be the column headers, and everything else would be data, like this…

ORDER_ID|CUSIP|TICKER|SEC_NAME|ORDER_QTY
1136324289|31393FHA7|FHR|FHR 2527 SG|169249.6824
1136324304|31393G2C7|FHR|FHR 2531 ST|214673.0105

We’ve got the XSL working to get the data, but we can’t get the header to output correctly. We just select the first tradedata_item element, then iterate the element name and separate them using | characters. Here is the full XSL…

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl"
    version="1.0" xmlns="http://schemas.com/enterprise/util/extractservice/v1"
    xmlns:o="http://schemas.com/enterprise/util/extractservice/v1" > 

    <!--  xsl:strip-space elements="*"/-->
    <xsl:output method="text" indent="no"/>

     <xsl:template match="/tradedata/tradedata_item[1]">
    <xsl:for-each select="*">
      <xsl:value-of select="local-name()"/>|
    </xsl:for-each>
    <xsl:text>&#10;</xsl:text>  
  </xsl:template>


    <xsl:template match="/">
    <xsl:for-each select="tradedata/tradedata_item">
    <xsl:value-of select="ORDER_ID"/>|<xsl:value-of select="CUSIP"/>|<xsl:value-of select="TICKER"/>|<xsl:value-of select="SEC_NAME"/>|<xsl:value-of select="ORDER_QTY"/>
    <xsl:text>&#10;</xsl:text>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

The output we’re seeing is just data, no header…

113632428|31393FHA7|FHR|FHR 2527 SG|169249.6824
113632430|31393G2C7|FHR|FHR 2531 ST|214673.0105
113632431|527069AH1|LESL|ZZZ_LESLIE S POOLMART INC|365000.0000
113632434|38470RAD3|GRAHAM|ZZZ_GRAHAM PACKAGING CO|595000.0000

Please disregard any namespace inconsistencies; I had to obfuscate the xml and xsl for legal reasons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:12:34+00:00Added an answer on May 26, 2026 at 1:12 am

    Try this :

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="text" indent="no"/>
    
    <xsl:template match="/">
    <xsl:for-each select="tradedata/tradedata_item[1]/*">
      <xsl:value-of select="concat(name(), '|')"/>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    

    Output :

    ORDER_ID|CUSIP|TICKER|SEC_NAME|ORDER_QTY|
    

    It seems pretty simple to me. Maybe your error lies elsewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the XSL: <?xml version=1.0 encoding=UTF-8?> <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:xs=http://www.w3.org/2001/XMLSchema exclude-result-prefixes=xs version=2.0> <xsl:output method=xml/> <xsl:template
I'm using Xsl transformation to display an Xml data as Html. <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I have an XML file that I am using XSL to convert into an
I am trying to remove the attribute xmlns=http://webdev2003.test.com from the following xml using xsl/xslt,
I'm trying to convert an XML file into the markup used by dokuwiki, using
I am using xsl to convert data from xml into C++ code. I am
I'm trying to transform one XML format to another using XSL. Try as I
I have report that I must convert to PDF using xsl-fo from xml data
I am using XSLT to convert a very large XML document into (X)HTML. For
I'm trying convert xml from one format to other using the XslCompiledTransform in c#.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.