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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:02:51+00:00 2026-06-15T13:02:51+00:00

If I have an xml with namespaces and want to apply some values replacement,

  • 0

If I have an xml with namespaces and want to apply some values replacement, what do I have to change?
http://xslt.online-toolz.com/tools/xslt-transformation.php

<?xml version="1.0"?>
<accounts>
<account>
<name>Alex</name>
</account>
<account>
<name>Fiona</name>
</account>
</accounts>

This will change alle name values to “Johndoe”:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
 </xsl:template>

  <xsl:template match="account/name/text()">
   <xsl:text>JohnDoe</xsl:text>
  </xsl:template>
</xsl:stylesheet>

But what if I have a namespace before very tag, like:

<?xml version="1.0"?>
<my:accounts>
<my:account>
<my:name>Alex</my:name>
</my:account>
<my:account>
<my:name>Fiona</my:name>
</my:account>
</my:accounts>
  • 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-15T13:02:52+00:00Added an answer on June 15, 2026 at 1:02 pm

    Two ways of doing this. Either include the ‘my’ namespace in the stylesheet tag like this:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="(insertnamespacehere)">

    and do

    <xsl:template match="my:account/my:name/text()">

    or do the rather clumsier:

    <xsl:template match="*[local-name()='account']/*[local-name()='name']/text()">

    I’d be inclined to discourage the latter approach though- namespaces exist to distinguish between elements that have the same local name (such as employee:name and company:name for example), by using local-name() you ignore that distinction. In other words, if your document happens to contains foo:account/foo:name, you’ll accidentally replace that too.

    Incidentally, your last sample XML isn’t valid- the my namespace is not declared. Your root my:accounts would need to include this with <my:accounts xlmns:my="(insertnamespacehere)">

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

Sidebar

Related Questions

I have the following snippet of XML: <?xml version=1.0 encoding=UTF-8?> <Envelope xmlns=http://schemas.microsoft.com/dynamics/2008/01/documents/Message> <Header> <MessageId>{11EA62F5-543A-4483-B216-91E526AE2319}</MessageId>
I want to have xml like <?xml version=1.0?> <root xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns=http://schema.test.com/test> <test1>1</test1> .
I have an XML document with un-namespaced elements, and I want to use XSLT
I have the following XML example: <?xml version=1.0 encoding=UTF-8?> <OpenSearchDescription xmlns=http://a9.com/-/spec/opensearch/1.1/ xmlns:custom=http://example.com/opensearchextensions/1.0/> <ShortName>Test</ShortName> <Description>Testing....</Description>
I have an XSLT stylesheet like the following: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I want to have JAXB-annotated classes which would be marshalled/unmarshalled to different XML namespaces
Some of the nodes in an XML document have namespaces, specified with a defined
I have XML that looks something like this: <Root xmlns=http://widgetspecA.com/ns> ...any... <WidgetBox> <A/> <B/>
I have several xml namespaces that expose the same schema. I want to use
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and

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.