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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:56:07+00:00 2026-05-15T04:56:07+00:00

I’m working on the code below to allow HTTP user agents that cannot perform

  • 0

I’m working on the code below to allow HTTP user agents that cannot perform XSL transformations to view the resources on my server. I’m mystified because the result of transformToXML is false, but the result of libxml_get_errors() is an empty array. As you can see, the code outputs the LibXSLT version ID and I’m getting the problem on WinVista with version 1.1.24. Is libxml_get_errors() not the right function to get the errors from the XSLTProcessor object?

If you’re interested in the XML documents, you can get them from http://bobberinteractive.com/index.xhtml and …/stylesheets/layout.xsl


<?php
//redirect browsers that can handle the source files.
if (strpos ( $_SERVER ['HTTP_ACCEPT'], 'application/xhtml+xml' )) {
 header ( "HTTP/1.1 301 Moved Permanently" );
 header ( "Location: http://" . $_SERVER ['SERVER_NAME'] . "/index.xhtml" );
 header ( "Content-Type: text/text" );
 echo "\nYour browser is capable of processing the <a href='/index.xhtml'> site contents on its own.";
 die ();
}
//start by checking the template
$baseDir = dirname ( __FILE__ );
$xslDoc = new DOMDocument ();
if (! $xslDoc->load ( $baseDir . '/stylesheets/layout.xsl' )) {
 header ( "HTTP/1.1 500 Server Error" );
 header ( "Content-Type: text/plain" );
 echo "\n Can't load " . $baseDir . '/stylesheets/layout.xsl';
 die ();
}

//resolve the requested resource (browsers that need transformation will request the resource without the suffix)
$uri = $_SERVER ['REQUEST_URI'];
$len = strlen ( $uri );
if (1 >= $len || '/' == substr ( $uri, $len - 1 )) {
 $fileName = $baseDir . "/index.xhtml"; // use 'default' document if pathname ends in '/'
} else {
 $fileName = $baseDir . (1 load ( $fileName )) {
 header ( "HTTP/1.1 500 Server Error" );
 echo "\n Can't load " . $fileName;
 die ();
}
// now start the XSL template processing
$proc = new XSLTProcessor ();
$proc->importStylesheet ( $xslDoc );
$doc = $proc->transformToXML ( $xmlDoc );
if (false === $doc) {
 header ( "HTTP/1.1 500 Server Error" );
 header ( "Content-Type: text/plain" );
 echo "\n";
 // HERE is where it gets strange: the value of $doc is false and libxml_get_errors returns 0 entries.
 display_xml_errors ( libxml_get_errors() );
 die ();
}
header ( "Content-Type: text/html" );
echo "\n";
echo $doc;

function display_xml_errors($errors) {
 echo count ( $errors ) . " Error(s) from LibXSLT " . LIBXSLT_DOTTED_VERSION;
 for($i = 0; $i level) {
   case LIBXML_ERR_WARNING :
    $return .= "Warning $error->code: ";
    break;
   case LIBXML_ERR_ERROR :
    $return .= "Error $error->code: ";
    break;
   case LIBXML_ERR_FATAL :
    $return .= "Fatal Error $error->code: ";
    break;
  }

  $return .= trim ( $error->message ) . "\n  Line: $error->line" . "\n  Column: $error->column";

  if ($error->file) {
   $return .= "\n  File: $error->file";
  }

  echo "$return\n\n--------------------------------------------\n\n";
 }
}

  • 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-15T04:56:08+00:00Added an answer on May 15, 2026 at 4:56 am

    I’m getting several errors when loading your XML or executing your XSL. Upgrade your error_reporting level

    error_reporting(E_ALL | E_STRICT);
    // or
    error_reporting(-1); // overzealous, but works
    

    Got me:

    PHP Warning:  DOMDocument::load(): Entity 'ndash' not defined in /tmp/index.xhtml, line: 8 in /tmp/test.php on line 4
    PHP Warning:  XSLTProcessor::importStylesheet(): compilation error: file /tmp/layout.xsl line 59 element a in /tmp/test.php on line 10
    PHP Warning:  XSLTProcessor::importStylesheet(): Attribute 'onclick': The content is expected to be a single text node when compiling an AVT. in /tmp/test.php on line 10
    PHP Warning:  XSLTProcessor::importStylesheet(): compilation error: file /tmp/layout.xsl line 185 element a in /tmp/test.php on line 10
    PHP Warning:  XSLTProcessor::importStylesheet(): Attribute 'onclick': The content is expected to be a single text node when compiling an AVT. in /tmp/test.php on line 10
    PHP Warning:  XSLTProcessor::transformToXml(): No stylesheet associated to this object in /tmp/test.php on line 12
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Don't use a regular expression. Use URI and URI::QueryParam, like… May 16, 2026 at 4:56 pm
  • Editorial Team
    Editorial Team added an answer The thing that you're trying to do here is called… May 16, 2026 at 4:56 pm
  • Editorial Team
    Editorial Team added an answer Generally, you should have no problems. sendmail (or equivalent) on… May 16, 2026 at 4:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want use html5's new tag to play a wav file (currently only supported
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.