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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:51:23+00:00 2026-06-06T03:51:23+00:00

I have a bunch of XML files I’m using for user interface and string

  • 0

I have a bunch of XML files I’m using for user interface and string translation in my project, each of which have the following structure:

<?xml version="1.0" encoding="UTF-8" ?>
<messages>
    <message id="x">
        <!-- Text node or arbitrary XHTML markup in here -->
    </message>
    <message id="y">
        <!-- Text node or arbitrary XHTML markup in here -->
    </message>
    <message id="z">
        <!-- Text node or arbitrary XHTML markup in here -->
    </message>
    ...
</messages>

As part of my build process I’d like to “minify” these files into a single XML file, whereby each <message> tag and all of its children are embedded within a <messages> tag.

The current solution I have is using grep to rip out the XML prolog, opening messages tag and closing messages tag from each file, and concatenating the result to a new file, after concatenating the XML prolog and opening messages, then finally concatenating the closing messages tag. This solution is… rather messy and error prone.

So, how can I use any command-line XML tools to automate this process? Could I use something like xmlpatterns and/or XSL transforms?

Side question: how would I verify that each <message> tag has an ID attribute, and that all ID attribute values in the final document are unique? I know I can do the first part by means of a DTD, but is the second also in the realm of DTDs or would I need to do something else?

  • 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-06-06T03:51:24+00:00Added an answer on June 6, 2026 at 3:51 am

    After some research and experimentation, I came up with the following solution:

    First I created an XML with a list of all of the XML files I wanted to combine together:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="merge-messages.xsl"?>
    <bundles>
        <bundle>file1.xml</bundle>
        <bundle>file2.xml</bundle>
        <bundle>file3.xml</bundle>
        ...
    </bundles>
    

    Then I wrote an XSL transform that selected the <message> tags from each file listed in the index file:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output omit-xml-declaration="no" indent="yes"/>
    
        <xsl:template match="/bundles">
            <messages>
                <xsl:apply-templates select="document(bundle)/messages/message"/>
            </messages>
        </xsl:template>
    
        <xsl:template match="message">
            <xsl:copy-of select="."/>
        </xsl:template>
    </xsl:stylesheet>
    

    I was using Qt in my project, and Qt happens to include a tool called xmlpatterns which can perform XSL transformations. So I was able to include the following command in my build process and have my XML files automatically “minified” on each build.

    xmlpatterns merge-messages.xsl messages-index.xml -output messages.xml
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of XML files which are using prefixes but without the
I have a huge bunch of XML files with the following structure: <Stuff1> <Content>someContent</name>
I have a bunch of XML files, along with the DTD, that each have
I have a bunch of wav files and corresponding XML files which contain times.
Background: In our project, we have a bunch of xml files that define tests
I have a bunch of XML files which I use to generate HTML pages.
I have a bunch of XML files that are about 1-2 megabytes in size.
I have a bunch of named value parameters in a Dictionary<string, object> , which
I have a bunch of xml files with a varying amount of data nodes
I have a bunch of .xml files with nodes that are causing uncessesary complications.

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.