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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:25:09+00:00 2026-06-12T15:25:09+00:00

Whilst transforming XHTML to XHTML with XSL I have a problem with namespaces. Consider

  • 0

Whilst transforming XHTML to XHTML with XSL I have a problem with namespaces. Consider as an example input:

<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>Test</title></head>
    <body>
        <p>Remove this</p>
    </body>
</html>

Then the following transformation does not work (e.g. does not remove the <p />):

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="@*|node()" name="copy">
        <xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
    </xsl:template>

    <xsl:template match="p" />
</xsl:stylesheet>

But this one does:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <xsl:template match="@*|node()" name="copy">
        <xsl:copy><xsl:apply-templates select="@*|node()" /></xsl:copy>
    </xsl:template>

    <xsl:template match="xhtml:p" />
</xsl:stylesheet>

My problem and question is: How can I change the XSLT so that I do not have to add prefixes to all the XHTML elements and it still get to match them? From what I tried so far, adding a default namespace like <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" /> does not achieve this.

Thanks for your help!

  • 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-12T15:25:10+00:00Added an answer on June 12, 2026 at 3:25 pm
    How can I change the XSLT so that I do not have to add prefixes to all the XHTML elements and it still get to match them?
    

    This is possible, but I would recommens defining the namespace and using the preefix in referring to elements in this namespace:

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

    Warning:

    This technique can be safe only if it is guaranteed that there arent two elements with the same local-name() but in different namespaces.

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

Sidebar

Related Questions

Whilst I'd love to solve this problem in python, I'm stuck in Delphi for
Whilst I don't have no ANALYSE issues with my iPhone code, when I run
Whilst developing a php class i have run into a rather interesting thing within
Whilst compiling with avr-gcc I have encountered linker errors such as the following: undefined
Whilst on my local machine the following code behaves perfectly. @Html.Raw(SquishIt.Framework.Bundle.Css() .Add(~/css/normalize.css) .Add(~/css/nonsemantic.css) .Add(~/css/custom/basic/site.css)
Whilst testing on the Android Emulator running Android 4.0 (Ice Cream Sandwich), I have
Whilst drawing on a SurfaceView, I'm having a problem intercepting a 'back' key press.
I have an issue whilst streaming to a file, I'm sure there is a
whilst designing the about page for my new service, i have stumbled across a
Yet another problem whilst trying to create the UI for an app. I've got

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.