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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:22:28+00:00 2026-05-10T19:22:28+00:00

An XSLT-newbie problem: I need to substitute a text value in XML-file. All other

  • 0

An XSLT-newbie problem: I need to substitute a text value in XML-file. All other nodes must be left unchanged. Here’s my input file (in.xml):

<?xml version='1.0' encoding='UTF-8'?> <root>     <level1 attr1='val1'>         <level2>in</level2>     </level1> </root> 

Here’s my XSLT-transformation (subst.xsl):

<?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>      <xsl:template match='/'>         <xsl:apply-templates />     </xsl:template>      <xsl:template match='//node()'>         <xsl:copy>             <xsl:apply-templates />         </xsl:copy>     </xsl:template>      <xsl:template match='/root/level1/level2/text()'>out</xsl:template> </xsl:stylesheet> 

I run it with the following Ant-script (build.xml):

<?xml version='1.0' encoding='UTF-8'?> <project name='test' default='test' basedir='.'>     <target name='test'>         <xslt style='subst.xsl' in='in.xml' out='out.xml' />     </target> </project> 

And here’s what I get (out.xml):

<?xml version='1.0' encoding='UTF-8'?><root>     <level1>         <level2>out</level2>     </level1> </root> 

Attribute ‘attr1’ of ‘level1’ is missing.

I would be very grateful if anyone

  • tell me what’s wrong with subst.xsl

OR

  • give me an idea how to force xslt-processor just copy non-matched nodes to output file and to do it by hand (which is in my case error-prone).
  • 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. 2026-05-10T19:22:28+00:00Added an answer on May 10, 2026 at 7:22 pm

    Your identity transform is missing attributes (obviously). Use this instead:

    <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>   <xsl:template match='@* | node()'>     <xsl:copy>       <xsl:apply-templates select='@* | node()'/>     </xsl:copy>   </xsl:template> </xsl:stylesheet> 

    Then, just add your last template.

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

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer http://www.vttoth.com/LPK/taskmanager.html This is kind of old, but might still work. May 11, 2026 at 11:11 am
  • added an answer Closing a c++ console app with the 'x' in the… May 11, 2026 at 11:11 am
  • added an answer There generally isn't a silver bullet in converting between table… May 11, 2026 at 11:11 am

Related Questions

An XSLT-newbie problem: I need to substitute a text value in XML-file. All other
I want to apply an XSLT Stylesheet to an XML Document using C# and
I have an xslt sheet with some text similar to below: <xsl:text>I am some
I want to attach an xslt stylesheet to an XML document that I build
Does anyone have an XSLT that will take the app.config and render it into
I have an XSLT for viewing XML files in the browser. The XSLT is
I have a java class that applies an xslt to all xml files in
I'm trying to run an XSLT transformation, but characters like ëöï are replaced by
I believe I need a DTD to define the schema and an XSLT if
I have the following situation: There is a tool that gets an XSLT from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.