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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:31:50+00:00 2026-05-19T17:31:50+00:00

I try to transform XHTML webpage using XSLT by extracting some of its parts.

  • 0

I try to transform XHTML webpage using XSLT by extracting some of its parts. For example, I’d like to extract HEAD and BODY parts separately (it’s only first step, next will be extracting some divs) and use them in my output XHTML document. Here is XSLT code:

<xsl:stylesheet version="2.0"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="xhtml xsl xs">

<xsl:output
  method="html"
  omit-xml-declaration="yes"
  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  indent="yes"/>


<xsl:template match="/">
  <HTML>
      <xsl:apply-templates/>
  </HTML>
</xsl:template>

<xsl:template match="xhtml:HTML/xhtml:BODY">
 <xsl:copy-of select="." disable-output-escaping="yes" />
</xsl:template>


<xsl:template match="xhtml:HTML/xhtml:HEAD">
  <xsl:copy-of select="." disable-output-escaping="yes"/>
</xsl:template>

</xsl:stylesheet>

As an input XHTML I have http://www.wordpress.org/about source code (validating).
As first neko purifier is fired (HTML->XHTML) and then my xslt transformation. When I take a look into output code everything looks similar:

Original code: codepad.org/5D7MCXSk
Code after transformation: http://codepad.org/fGzyAwF2

Except, when I open it in web browser I get “white wall” – nothing appears. I noticed that in source code of transformed site (both on chrome and firefox) syntax is highlighted up to the closing HEAD tag. It is very weird and I thing that it is causing the problem.

Any help will be very appreciated.
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-19T17:31:50+00:00Added an answer on May 19, 2026 at 5:31 pm

    So it seems that http://codepad.org/5D7MCXSk (code 1) is the same as the source code of http://wordpress.org/about/ (code 2) and you process this code with “neko purifier” (is it this one: http://nekohtml.sourceforge.net/ ?) resulting the document in http://codepad.org/fGzyAwF2 (code 3). Correct me if I’m wrong.

    The reason why code 3 doesn’t show anything in the browser seems to be a self closing <SCRIPT/> at the end of the <HEAD>. YMMW, but in my tests for some reason the browsers didn’t seem to like it.

    Your XSLT code is slightly flawed but if you feed the code 3 as input, it produces an output. The quirk of the input file, that self closing script element, is preserved in the transformation.

    Some random notes:

    • The original input (code 1) is well formed XML, so you don’t need to “purify” it
    • <xsl:copy-of> doesn’t have attribute disable-output-escaping
    • There is no sense in defining a default namespace for output document when using method="html" because html doesn’t use namespaces (unlike xhtml)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to transform a string that contains an xml using a XSLT, it's
I try to transform a hierarchical XML file to a flat file schema using
I'm trying to transform one XML format to another using XSL. Try as I
I am using Javascript to load XML and transform it with XSLT. Everything works
I have try to standardize signature in my company. <html xmlns=http://www.w3.org/1999/xhtml > <head> <style
I try to transform my div container like the following picture. Left is a
My xslt transform does not pick up my document, this is because some/most elements
I have an XSLT transform I am using to process an XML file, inserting
I am using XSLT to transform XML to HTML. Currently i am trying to
I tried to perform XSLT transform of a XSD file. My goal is in

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.