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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:07:27+00:00 2026-05-23T09:07:27+00:00

Running XSLTprocessor under PHP 5.2.11, I’ve run into an odd bug and have been

  • 0

Running XSLTprocessor under PHP 5.2.11, I’ve run into an odd bug and have been able to replicate it with the W3Schools XSLT demo as well.

This is the streamlined case, which still produces the bug.
My goal is to take hierarchically structured XML and “flatten” it to create a row structure.

Input:

<?xml version="1.0"?>
<profiles>
<Subrecipient>
    <SubrecipientName>TESTING123</SubrecipientName>
    <Service>
        <ServiceName>BEFORE</ServiceName>
        <area>BETWEEN</area>
        <TypeDesc>AFTER</TypeDesc>
    </Service>
</Subrecipient>
</profiles>

Stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<!--generally, don't output nodes that have no children -->
<xsl:template match="//*[not(*)]" />
<!-- except in "dataout" mode, namely when we're matching at a low level -->
<xsl:template match="//*[not(*)]" mode="dataout" >
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="Service">
<row>
<!--next line selects all childless children of ancestors -->
<xsl:apply-templates select="ancestor::*/child::*[not(*)]" mode="dataout" />
<xsl:apply-templates  select="*[not(*)]" mode="dataout"  /> 
</row>
</xsl:template>
</xsl:stylesheet>

Desired output (spacing for clarity):

<row><subrecipientname>TESTING123</subrecipientname>
     <servicename>BEFORE</servicename>    
     <area>BETWEEN</area>
     <typedesc>AFTER</typedesc>
</row>    

Actual output (for instance, from the W3Schools XSLT demo linked above):

<row><subrecipientname>TESTING123</subrecipientname>
      <servicename>BEFORE</servicename>
      <area>
      <typedesc>AFTER</typedesc>
</row>

I.e. the XSLT processes generates bad xml, omitting both the content and the closing tag for the “area” element. If I rename that element as “area_”, all is well.

I don’t know what XSLT processor W3Schools is using, so perhaps this is just a PHP XSLTprocessor bug, or there’s something deep (and wonderful?) about XSLT and XPATH I don’t understand.

I’ve got a workaround, but I’d prefer to understand what I’ve run into here. Thanks for any 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-05-23T09:07:28+00:00Added an answer on May 23, 2026 at 9:07 am

    Yes, this is correct; the main cause of this is that you are using xsl:output with html method. With this, the processor is allowed to output non well formed documents. The area tag is an HTML tag without end tag as many others like br and so on. You can resolve your problem just be changing output method to XML.

    <xsl:output method="xml"/>
    

    You may experience the same behavior with any XSLT 1.0 compliant processor (like Saxon 6.5).

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

Sidebar

Related Questions

Running into a problem. I have a table defined to hold the values of
Running into the strangest problem on iPhone using jQuery with my WebViewController. I have
Running Fedora 9/10, Apache 2, PHP 5... Can I run a shell script as
Running into a problem where on certain servers we get an error that the
Running OS X Leopard an MacBook Pro from Jan. 2008. I used to run
Running ipconfig /all shows a Teredo Tunneling Pseudo-Interface. What is that? Does this have
I have the following PHP code, but it's not working. I don't see any
Running SQL Server 2008, and I am definitely a new SQL user. I have
Running the ASP.NET webforms run the application works fine. When the application is idle
Running into strangeness with get_payload: it seems to crap out when it sees an

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.