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 6600215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:35:34+00:00 2026-05-25T18:35:34+00:00

<?xml version=1.0 encoding=utf-8?> <Report p1:schemaLocation=Customer details http://reportserver?%2fCustomer details&amp;rs%3aFormat=XML&amp;rc%3aSchema=True Name=Customer details xmlns:p1=http://www.w3.org/2001/XMLSchema-instance xmlns=Customer details> <table2>

  • 0
<?xml version="1.0" encoding="utf-8"?>
<Report p1:schemaLocation="Customer details  http://reportserver?%2fCustomer details&amp;rs%3aFormat=XML&amp;rc%3aSchema=True" Name="Customer details" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="Customer details">
  <table2>
   <Detail_Collection>
         <Detail Col1="aaa" col1_SeqID="2"  col1_Include="1"
                 Col2="aaa" col2_SeqID="1"  col2_Include="1"
                 Col3="aaa" col3_SeqID=""  col3_Include="0"
                 Col4="aaa" col4_SeqID="4"  col4_Include="1"
                 Col5="aaa" col5_SeqID=""  col5_Include="0"
                 ... ... ...
                 ... ... ...
                 ... ... ...
                 Col50="aaa" col50_SeqID="3"  col50_Include="1"
                 />
   <Detail_Collection>
</table2>
</Report>

The above xml is produced by SSRS for the RDL file. I want to transform the above xml file to CSV format using XSLT (customized format).
The RDL file (SSRS report) is very simple with 50 columns, and displays the data for all the columns depending on the user selection on the user interface.
The user interface has got the parameter selection for all the 50 columns (i.e they can select the order of the column, they can select a particular column to be included on the report or not, the fontstyle etc…). As mentioned the each column has 2 main functionalities i.e. they can be sorted and as well ordered by based on the selections.

For example from the report output i.e in the xml format given above you will see all the 50 columns exist on the xml format but I am also including the extra fiedls which are generally hided on the report.

The col1 is included on the report and is ordered (seqID) as the 2nd column on the csv file.
The col2 is also included on the report and is ordered as the 1st column on the csv file.
The col3 is not included on the report and the order selection is empty, so this is not included on the csv file.
…
…
like wise the col50 is included on the report but is ordered in as 3rd column in the csv file.

My main challenge here to create the xslt file for “CSV” and put the columns in the order selection which are selected per user basis.

The output in the CSV file after transformation will look as follows:

Col2    Col1    Col50   Col4
 ...  ...       ...     ....

Any good idea to create this kind of xsl file is much appreciated and I thank you so much for understanding my question and trying to help me in this regard.

  • 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-25T18:35:34+00:00Added an answer on May 25, 2026 at 6:35 pm

    I. This XSLT 1.0 transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:c="Customer details">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="c:Detail">
         <xsl:apply-templates select=
          "@*[substring(name(), string-length(name())-5)
             = '_SeqID'
            and
              number(.) = number(.)
              ]
         ">
          <xsl:sort data-type="number"/>
         </xsl:apply-templates>
     </xsl:template>
    
     <xsl:template match="@*">
      <xsl:if test="not(position()=1)">,</xsl:if>
      <xsl:value-of select=
        "../@*
           [name()
           =
            concat('Col',substring-before(substring(name(current()),4),'_'))
            ]"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on this XML document (the provided one, made well-formed and unambiguous):

    <Report
    p1:schemaLocation="Customer details  http://reportserver?%2fCustomer details&amp;rs%3aFormat=XML&amp;rc%3aSchema=True"
    Name="Customer details"
    xmlns:p1="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="Customer details">
        <table2>
            <Detail_Collection>
                <Detail Col1="aaa1" col1_SeqID="2"  col1_Include="1"
                Col2="aaa2" col2_SeqID="1"  col2_Include="1"
                Col3="aaa3" col3_SeqID=""  col3_Include="0"
                Col4="aaa4" col4_SeqID="4"  col4_Include="1"
                Col5="aaa5" col5_SeqID=""  col5_Include="0"
                Col50="aaa50" col50_SeqID="3"  col50_Include="1"
                />
            </Detail_Collection>
        </table2>
    </Report>
    

    produces the wanted, correct result:

    aaa2,aaa1,aaa50,aaa4
    

    Explanation:

    1. We use that the XPath 1.0 expression:

    __

    substring($s1, string-length($s1) - string-length($s2) +1) = $s2
    

    is equivalent to the XPath 2.0 expression:

    ends-with($s1, $s2))
    

    .2. Appropriate use of <xsl:sort>, substring(), name() and current().

    .3. Using the fact that a string $s is castable to number if and only if:

    __

    number($s) = number($s)
    

    II. XSLT 2.0 solution:

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:c="Customer details">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>    
    
     <xsl:template match="c:Detail">
             <xsl:apply-templates select=
              "@*[ends-with(name(),'_SeqID')
                and . castable as xs:integer]">
              <xsl:sort  select="xs:integer(.)"/>
             </xsl:apply-templates>
     </xsl:template>
     <xsl:template match="@*">
          <xsl:if test="not(position()=1)">,</xsl:if>
          <xsl:value-of select=
            "../@*
               [name()
               eq
                concat('Col',translate(name(current()),'col_SeqID',''))]"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the same XML document (above), the same correct result is produced:

    aaa2,aaa1,aaa50,aaa4
    

    Update: @desi has asked that the heading should also be generated.

    Here is the updated XSLT 1.0 transformation (as indicated, @desi is limited to use XSLT 1.0 only) that does this:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:c="Customer details">
     <xsl:output method="text"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="c:Detail">
    
         <xsl:for-each select=
          "@*[substring(name(), string-length(name())-5)
             = '_SeqID'
            and
              number(.) = number(.)
              ]
            ">
            <xsl:sort data-type="number"/>
    
           <xsl:value-of select=
           "concat('Col',
                   substring-before(substring(name(current()),4),
                                    '_')
                   )
           "/>
    
              <xsl:text>&#9;</xsl:text>
         </xsl:for-each>
         <xsl:text>&#10;</xsl:text>
    
         <xsl:apply-templates select=
          "@*[substring(name(), string-length(name())-5)
             = '_SeqID'
            and
              number(.) = number(.)
              ]
         ">
          <xsl:sort data-type="number"/>
         </xsl:apply-templates>
     </xsl:template>
    
     <xsl:template match="@*">
      <xsl:if test="not(position()=1)">,</xsl:if>
      <xsl:value-of select=
        "../@*
           [name()
           =
            concat('Col',substring-before(substring(name(current()),4),'_'))
            ]"/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the same XML document (above), the wanted, correct result is produced:

    Col2    Col1    Col50   Col4    
    aaa2,aaa1,aaa50,aaa4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?xml version=1.0 encoding=utf-8?> <Report p1:schemaLocation=TemplateXXX http://localhost?language=en Name=TemplateXXX xmlns:p1=http://www.w3.org/2001/XMLSchema-instance xmlns=TemplateXXX> <HEADER attr1=one attr2=two /> <Table
Given below is my xml: <?xml version=1.0 encoding=utf-8?> <Report xmlns:rd=http://schemas.microsoft.com/SQLServer/reporting/reportdesigner xmlns=http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition> <Body> <ReportItems> <Textbox
Here's the XML: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <feed xmlns=http://www.w3.org/2005/Atom xmlns:dc=http://purl.org/dc/elements/1.1/> <title>Rated Images</title> <link
I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have the following XML document <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009' gd:etag='W/DEAERH47eCl7ImA9WhZTFEQ.'><id>http://code.google.com/feeds/issues/p/chromium/issues/full/921</id><published>2008-09-03T22:51:22.000Z</published><updated>2011-03-19T01:05:05.000Z</updated><title>Incorrect rendering</title><content
The following .jrxml: <?xml version=1.0 encoding=UTF-8?> <jasperReport xmlns=http://jasperreports.sourceforge.net/jasperreports xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd name=DTC-Campaigns-Block-Campaigns-Helper-Campaigns language=groovy pageWidth=794
<?xml version=1.0 encoding=utf-8 ?> <reportgroups> <Reportgroup id=1 name=reportGroup1> <report id=1 name=report1 isSheduled=false></report> <report id=2
My errors/local.xml content: <?xml version=1.0 encoding=UTF-8?> <config> <skin>default</skin> <report> <action>print</action> <subject>Store Debug Information</subject> <email_address></email_address>
My select_screen_menu.xml <?xml version=1.0 encoding=utf-8?> <menu xmlns:android=http://schemas.android.com/apk/res/android> <item android:id=@+id/home_menu android:icon=@drawable/home_tab android:title=Home /> <item android:id=@+id/submit_report
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1

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.