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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:39:30+00:00 2026-05-12T07:39:30+00:00

I want to translate an XML file with data like the following: <FlatData> <Details1_Collection>

  • 0

I want to translate an XML file with data like the following:

<FlatData>
    <Details1_Collection>
        <Details1 Customer1="Customer" Total1="3" />
        ...
    </Details1_Collection>
</FlatData>

The data I am interested in is the attributes and their values in each Details1. The problem is that these attributes are not necessarily going to be the same in every XML file I want to translate, and I want a general purpose XSL that could handle such Details1 as these:

<Details1 Customer1="Customer" Total1="3" />
<Details1 Name="Jim" Age="14" Weight="180" />
<Details1 Date="2009-07-27" Range="1-5" Option1="True" />

These different Details1 would not occur in the same source XML file, but rather in different files. However, I would like to use the same XSL on each.

I was thinking I needed something like <xsl:value-of select="@attribute_name"/> but what do I put for @attribute_name when I don’t know beforehand what attributes there will be? Also, how do I capture the attribute name? I would like to explode the source XML above to something like:

<Details1>
    <Customer1>Customer</Customer1>
    <Total1>3</Total1>
</Details1>

Edit: thanks for the responses! I’m having trouble getting more than the following output, however:

<?xml version="1.0" encoding="UTF-8"?>
<FlatData>
<Details1_Collection></Details1_Collection>
</FlatData>

I’ve tried both lavinio’s and Jörn Horstmann’s answers, as well as trying to combine the two. I run this command:

msxsl.exe -o output.xml input.xml transform.xsl

I think something that’s getting in the way is a namespace in the input file:

<Report Name="MyReport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="MyReport">
  • 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-12T07:39:30+00:00Added an answer on May 12, 2026 at 7:39 am

    There was increased difficulty because of the Microsoft SQL Reporting Services 2008 namespace that was part of the input XML. I didn’t realize at first that <Report Name="MyReport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="MyReport"> was such an important line. Thanks to Pavel Minaev for the namespace comment. The following XSL worked to extract the data I wanted:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="EXQC005">
      <xsl:output method="xml" indent="yes" encoding="utf-8"/>
    
      <xsl:template match="/">
        <xsl:for-each select="a:Report/a:FlatData/a:Details1_Collection/a:Details1">
          <xsl:element name="{name(.)}">
            <xsl:for-each select="@*">
              <xsl:element name="{name(.)}">
                <xsl:value-of select="."/>
              </xsl:element>
            </xsl:for-each>
          </xsl:element>
        </xsl:for-each>
      </xsl:template>
    </xsl:stylesheet>
    

    I think I will try to clean this up to use the apply-templates style that lavinio suggested. Thanks also to Jörn Horstmann for the select="@*" code in for-each loops. It would be interesting to figure out why Reporting Services reports are dumped initially with the xmlns value set to the name of the report, and not a schema URL.

    I’ll continue to update this answer as I refine this XSL.

    Edit: here’s a namespace-agnostic version since, for each different report from Reporting Services, there will apparently be a different namespace:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" indent="yes" encoding="utf-8"/>
    
      <xsl:template match="/">
        <xsl:for-each select="*[local-name()='Report']/*[local-name()='FlatData']/*[local-name()='Details1_Collection']/*[local-name()='Details1']">
          <Details>
            <xsl:for-each select="@*">
              <xsl:element name="{name(.)}">
                <xsl:value-of select="."/>
              </xsl:element>
            </xsl:for-each>
          </Details>
        </xsl:for-each>
      </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to translate a given XML file (it is a RelaxNG grammar) to
I want to translate following simple sql query into Linq to NHibernate: SELECT NewsId
I want to translate a frontend Magento store using only one csv file. So
I have a lot of text data and want to translate it to different
I have a xml document, now i want to translate it to another xml
I am searching an xml file that looks like this: <producers> <producer> <name></name> <owner></owner>
I want to show two animation simultaneously programatically not in XML file.It should ROTATE
I want to translate app in Android (strings.xml and array.xml), but I don't know
Simple situation... With any random XML file, I want to create a list of
I am getting an XML file that I need to translate into another standard

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.