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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:04:44+00:00 2026-06-13T21:04:44+00:00

I would like to modify attribute value of element with name FOO, so I

  • 0

I would like to modify attribute value of element with name “FOO”, so I wrote:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" indent="yes"/>

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

  <xsl:template match="FOO/@extent">
      <xsl:attribute name="extent">
      <xsl:text>1.5cm</xsl:text>
      </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>

This stuff works. At now I need the same thing, but with element “fs:BOO”.
I tried replace FOO with “fs:BOO”, but xsltproc say that it can not compile
such code. I temporary solve this problem in such way:

sed 's|fs:BOO|fs_BOO|g' | xsltproc stylesheet.xsl - | sed 's|fs_BOO|fs:BOO|g'

but may be there is more simple solution, without usage of “sed”?

Example of input data:

<root>
    <fs:BOO extent="0mm" />
</root>

if write:

<xsl:template match="fs:BOO/@extent">

I got:

xsltCompileStepPattern : no namespace bound to prefix fs
compilation error: file test.xsl line 10 element template
xsltCompilePattern : failed to compile 'fs:BOO/@extent'
  • 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-13T21:04:46+00:00Added an answer on June 13, 2026 at 9:04 pm

    Firstly, I would expect your XML to have a declaration for the namespace, otherwise it will not be valid

    <root xmlns:fs="www.foo.com">
        <fs:BOO extent="0mm" />
    </root>
    

    And this also applies to your XSLT. If you are trying to do <xsl:template match="fs:BOO/@extent"> then you need a declaration to the namespace in your XSLT too.

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

    The important thing is the the namespace URI matches the one in the XML.

    If, however, you want to cope with different namespaces, you can take a different approach. You could use the local-name() function to check the name of element without the namespace prefix.

    Try this XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="@* | node()">
          <xsl:copy>
              <xsl:apply-templates select="@* | node()"/>
          </xsl:copy>
      </xsl:template>
    
      <xsl:template match="*[local-name()='BOO']/@extent">
          <xsl:attribute name="extent">
             <xsl:text>1.5cm</xsl:text>
          </xsl:attribute>
      </xsl:template>
    </xsl:stylesheet>
    

    This should output the following

    <root xmlns:fs="fs">
       <fs:BOO extent="1.5cm"></fs:BOO>
    </root>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following this question: Modify attribute of element , I would like to know if
I would like to modify an attribute of a very long xml like this:
I would like to modify a Spotlight metadata attribute of a file within my
I would like to modify updated_at attribute so that every time record is updated
I would like to select a node and modify its attributes and child-nodes using
I would like modify HTML like I am <b>Sadi, novice</b> programmer. to I am
I would like to modify an object private variable class Example(): __myTest1 = 1
We have a customer that would like to modify application user messages that we
I'm absolutely new to JavaScript and would like to modify a textarea of a
I'm using HighLine to write my console application and I would like to modify

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.