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

  • Home
  • SEARCH
  • 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 3500464
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:44:13+00:00 2026-05-18T12:44:13+00:00

I have XML file which is looks like: <Report> <Total> <RecordValues> <Record> <FieldValue fieldName=index

  • 0

I have XML file which is looks like:

<Report>
<Total>
    <RecordValues>
        <Record>
        <FieldValue fieldName="index"       fieldValue="1" />
        <FieldValue fieldName="version"     fieldValue="100" />
        <FieldValue fieldName="user"        fieldValue="tester" />
        <FieldValue fieldName="date_modified"   fieldValue="2010-10-18 12:18:12" />
        <FieldValue fieldName="object_name"     fieldValue="Menu" />
        <FieldValue fieldName="permission"  fieldValue="Permission X" />
        </Record>
        <Record>
        <FieldValue fieldName="index"       fieldValue="2" />
        <FieldValue fieldName="version"     fieldValue="100" />
        <FieldValue fieldName="user"        fieldValue="user1" />
        <FieldValue fieldName="date_modified"   fieldValue="2010-12-15 12:18:12" />
        <FieldValue fieldName="object_name"     fieldValue="Control" />
        <FieldValue fieldName="permission"  fieldValue="Permission E" />
        </Record>
        <Record>
        <FieldValue fieldName="index"       fieldValue="3" />
        <FieldValue fieldName="version"     fieldValue="15" />
        <FieldValue fieldName="user"        fieldValue="user2" />
        <FieldValue fieldName="date_modified"   fieldValue="2010-10-02 12:18:12" />
        <FieldValue fieldName="object_name"     fieldValue="Run" />
        <FieldValue fieldName="permission"  fieldValue="Permission R" />
        </Record>
    </RecordValues>
</Total>

I have to convert it with XSLT into formated text file:

1 100  101810
tester  Menu       Permission X
2 100  121510
user1   Control    Permission E
3 15   100210
user2   Run        Permission R 

The only fieldValue attribute must be used and all fields in the text file have fixed length.
Please help me.
Thanks.

  • 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-18T12:44:14+00:00Added an answer on May 18, 2026 at 12:44 pm

    This stylesheet:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:m="map">
        <xsl:output method="text"/>
        <xsl:strip-space elements="*"/>
        <xsl:variable name="vPadding"
             select="'             &#xA;                               '"/>
        <m:m n="index" p="1"/>
        <m:m n="version" p="3"/>
        <m:m n="user" p="15"/>
        <m:m n="date_modified" p="8"/>
        <m:m n="object_name" p="23"/>
        <m:m n="permission" p="34"/>
        <xsl:template match="Record">
            <xsl:apply-templates select="*[1]"/>
        </xsl:template>
        <xsl:template match="FieldValue">
            <xsl:param name="pOutput" select="$vPadding"/>
            <xsl:variable name="vValue">
                <xsl:apply-templates select="@fieldValue"/>
            </xsl:variable>
            <xsl:variable name="vPos"
                          select="document('')/*/m:m
                                     [@n=current()/@fieldName]/@p"/>
            <xsl:variable name="vOutput"
                 select="concat(substring($pOutput,1,$vPos -1),
                                $vValue,
                                substring($pOutput,$vPos+string-length($vValue)))"/>
            <xsl:variable name="vNext" select="following-sibling::*[1]"/>
            <xsl:apply-templates select="$vNext">
                <xsl:with-param name="pOutput" select="$vOutput"/>
            </xsl:apply-templates>
            <xsl:if test="not($vNext)">
                <xsl:value-of select="concat($vOutput,'&#xA;')"/>
            </xsl:if>
        </xsl:template>
        <xsl:template match="@*[../@fieldName='date_modified']">
            <xsl:value-of select="concat(substring(translate(.,'-',''),5,4),
                                         substring(.,3,2))"/>
        </xsl:template>
    </xsl:stylesheet>
    

    Output:

    1 100  101810
    tester  Menu       Permission X
    2 100  121510
    user1   Control    Permission E
    3 15   100210
    user2   Run        Permission R
    

    Note: Fine grained traversal, a padding mask, inline map with value starting position.

    EDIT: Strip space just in case…

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

Sidebar

Related Questions

I have XML file which looks like this: <?xml version=1.0?> <results> <row id=100><name>name blah</name></row>
I have an XML file which looks like this : <?xml version=1.0 encoding=UTF-8?> <resultset
Say I have an XML file which looks like this: <?xml version=1.0 encoding=UTF-8?> <Project
I have sitemap which looks like this: <?xml version=1.0 encoding=utf-8 ?> <siteMap xmlns=http://schemas.microsoft.com/AspNet/SiteMap-File-1.0 >
I have an XML file which looks like the following: <a> ...... <b> <c>
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have a PreferenceActivity that loads its preferences from an XML file which looks
i have an xml i load within my air app which looks like this:
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
Good morning. I have an XML file which contains lists of warning and errors

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.