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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:01:28+00:00 2026-05-13T11:01:28+00:00

I am writing an XSL template that pulls data from many secondary sources. An

  • 0

I am writing an XSL template that pulls data from many secondary sources. An example secondary document looks like this:

<toplevel xmlns:foo1="http://foo1">
 <path xmlns="http://foo1">
   <mytag>bar</mytag>
  </path>
</toplevel>

In the XSL, I am doing this:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:foo1="http://foo1"
 exclude-result-prefixes="foo1">
  <xsl:variable name="secondary1" select="document('secondary1.xml')/toplevel"/>
  <foo>
    <xsl:value-of select="$secondary1//foo1:path/foo1:mytag"/>
  </foo>
</xsl:stylesheet>

With a lot of secondary sources, each of which uses a different namespace, prefixing every single tag is tedious, and that much repetition can’t be the right thing to do anyway. Is there a way to use document() such that the namespace of the imported node-set is stripped (or to achieve the same effect another way)?

  • 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-13T11:01:28+00:00Added an answer on May 13, 2026 at 11:01 am

    In essence, a node with a namespace is an entirely different animal than a node with another namespace – even if they happen to share the same local name. (This is much the same way namespaces work everywhere else – there is really no easy way of “ignoring” namespaces. Think of ignoring namespaces when referring to classes in C#.)

    The clean approach would be to mention each namespace you might encounter in the XSLT and work with prefixes, even if it seems repetitive.

    The not-so-clean way is this:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    >
      <xsl:variable name="secondary1" select="document('secondary1.xml')"/>
    
      <xsl:template match="/">
        <foo source="1">
          <xsl:value-of select="
            $secondary1//*[local-name() = 'path']/*[local-name() = 'mytag']
          "/>
        </foo>
      </xsl:template>
    </xsl:stylesheet>
    

    This is not really more pleasing to the eye than working with prefixes, it’s longer and harder to read, it is ambiguous, and last but not least – it is slower because the engine must test a predicate on every step on the XPath. Take your pick.

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

Sidebar

Related Questions

No related questions found

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.