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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:21:47+00:00 2026-05-25T15:21:47+00:00

I have an issue of using PHP 5’s XSLTProcessor to manipulate the following XML

  • 0

I have an issue of using PHP 5’s XSLTProcessor to manipulate the following XML document. The issue is not the output being processed by the XSLT but elements of the html output are getting xmlns:php=”http://php.net/xsl” added to them. An example is below.

The PHP:

$xmldoc = DOMDocument::load($xml);
$xsldoc = DOMDocument::load($xslt);
$proc = new XSLTProcessor();
$proc->registerPHPFunctions();
$proc->importStyleSheet($xsldoc);
echo $proc->transformToXML($xmldoc);

The XML:

<allusers>
 <user>
  <uid>bob</uid>
 </user>
 <user>
  <uid>tom</uid>
 </user>
</allusers>

The XSLT:

 <?xml version="1.0"?>
 <xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:php="http://php.net/xsl"
  xsl:extension-element-prefixes="php">

 <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>

 <xsl:template match="allusers">
  <h2>Users</h2>
  <table>
   <xsl:for-each select="user">
   <tr><td>
    <xsl:value-of select="php:function ('MyClass::firstLetter',string(.))"/>
   </td></tr>
   </xsl:for-each>
  </table>
 </xsl:template>

 </xsl:stylesheet>

And the odd output (notice the xmlns:php=”http://php.net/xsl&#8221;):

<!DOCTYPE html> 
<html> 
<head></head>
<body>
 <h2 xmlns:php="http://php.net/xsl">Users</h2>
 <table xmlns:php="http://php.net/xsl">
  <tr><td>b</td></tr>
  <tr><td>t</td></tr>
 </table>
</body>
</html>

Any ideas? I’m sure that I have all the imports I need and am using them correctly but if someone can show me what or where I’m going wrong, that would be great. Thanks in advance.

  • 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-25T15:21:48+00:00Added an answer on May 25, 2026 at 3:21 pm
     <xsl:stylesheet version="1.0"    
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   
      xmlns:php="http://php.net/xsl"   
      xsl:extension-element-prefixes="php">
    

    You need to add:

     exclude-result-prefixes="php" 
    

    The exclude-result-prefixes attribute designates a list of prefixes and the namespaces bound to these prefixes are to be excluded (not copied) on literal result elements.

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

Sidebar

Related Questions

We have an issue using the PEAR libraries on Windows from PHP . Pear
I have the following issue using java 1.4 I try to display a very
I have an issue with using AWK to simply remove a field from a
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have this strange issue with my web app. You see, I'm using jQuery
In using our TeamCity Continuous Integration server we have uncovered some issues that we
I have been using PLT Scheme , but it has some issues. Does anyone
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it
We have an issue related to a Java application running under a (rather old)

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.