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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:50:48+00:00 2026-05-25T06:50:48+00:00

I have a large number of HTML files that I need to process with

  • 0

I have a large number of HTML files that I need to process with XSLT, using an XML file to choose which HTML files, and what we’re doing with them.

I tried:

  1. Use HTML Tidy to convert HTML -> XHTML / XML
  2. Use document(filename) in XSLT to read in particular XHTML/XML files
  3. …use standard nodeset commands to access e.g. “html/body/*”

This doesn’t work, because:

  1. It seems that XSLT (tried: libXSLT/xsltproc … and Saxon) cannot process XHTML documents as external files (it sees the xhtml DOCTYPE, and refuses to parse it as nodes).

Fine (I thought) … XHTML is just XML, I just need to put it through HTML Tidy and say:

“output-xml yes … output-html no … output-xhtml no”

…but HTML Tidy ignores you if you attempt that, and forces html instead :(. It seems to be hardcoded to only output XML files if the input was XML to begin with.

Any ideas for how to:

  1. Force HTML Tidy to obey the command-line parameters, and set the doctype I asked for
  2. Force XSLTproc to parse xhtml DOCTYPEs as xml
  3. …some other cunning way that will work?

NB: this has to work on OS X – it’s part of a build process for iOS apps. That shouldn’t be a big problem, but e.g. any windows-only tools aren’t available. I’d like to achieve this with standard open-source cross-platform tools (like tidy, libxslt, etc)

  • 1 1 Answer
  • 1 View
  • 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-25T06:50:49+00:00Added an answer on May 25, 2026 at 6:50 am

    I finally discovered why XSLTproc / Saxon were refusing to parse the files if they were passed-in with a DOCTYPE html:

    The DOCTYPE of the external document alters how they interpret the
    xmlns (namespace) directive. Tidy was declaring (correctly)
    “xmlns=…the xhtml: namespace” – so all my node-names were … I don’t know: non-existent? … inside my XSLT. XSLT was just ignoring them, as if they didn’t exist – it needed me to provide a compatible mapping to the same namespace

    …strangely, if the DOCTYPE was xml, then they happily ignored the xmlns command – or they allowed me to reference nodes by unqualified name. This fooled me into thinking that they were point-blank ignoring the nodesets inside the xhtml DOCTYPE’d version.

    So, the “solution” is something like this:

    1. modify your XSLT stylesheet to ALSO import the “xhtml” namespace – NB: this is required so that you can reference the nodes in the external files
    2. write all your XSL match / select / template rules with the “xhtml” prefix on every node (and every attribute, I think?)
    3. let Tidy output whatever it wants: it doesn’t matter, it’ll Just Work, once you have the namespace support in there

    Example code:

    1. Your stylesheet goes from this:

      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      

      …to this:

      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
      
    2. Your select / match / document-import goes from this:

      <xsl:copy-of select="document('html-files/file1.htm')/html/body"/>
      

      …to this:

      <xsl:copy-of select="document('html-files/file1.htm')/xhtml:html/xhtml:body"/>
      

    NB: just to be clear: if you ignore namespaces, then it seems XSLT will work on files that are unDOCTYPED, even if they have a namespace in them. Don’t make the mistake I made of thinking your XSLT is correct just because it appears to be 🙂

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

Sidebar

Related Questions

I have a large number of html documents that need a variable number of
I have an HTML table with a large number of rows, and I need
I have a large number of csv files that look like this below: xxxxxxxx
I am using about a dozen XSLT files to provide a large number of
I am working with a large number of HTML files that are mostly encoded
I have large number of HTML files where I have to do a global
I have a large number of basic text, rtf, html, pdf and chm files
I have a large number of records (10,000, increasing every day) that essentially is
I have a large number of documents (mainly PDFs) that I want to index
We have a large number of programmers on different platforms all using CVS. We

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.