Closed (fixed)
Project:
Import HTML
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 May 2010 at 17:03 UTC
Updated:
4 Jun 2010 at 01:50 UTC
Using the html2simplehtml.xsl stylesheet the module is apparently set to grab the
field and use that for the page title. I'd like it to use the field instead. How do I rewrite the xsl code to make it do that?
Comments
Comment #1
teschek commentedSorry, should have previewed that before sending. Adding the H1 html tag in the body of my question wasn't a good idea! My question again:
Using the html2simplehtml.xsl stylesheet the module is apparently set to grab the H1 field and use that for the page title. I'd like it to use the html Title field instead. How do I rewrite the xsl code to make it do that?
Comment #2
teschek commentedIs there answer to this question? Is it not something that import_html can do?
Comment #3
dman commentedYes, the HI is the default.
titleis supported as a fallback.The code is (comparatively) a really easy small XSL tweak.
The following code is very generic and tries to make some guesses, depending on IDs or other ways a page-title may occur in a document.
(You'll see why I don't use
<title>by default in the comments above)In practice, if you actually know that all you want is the
<title>then all you need is a line like:Life is MUCH easier when you don't have to rely on all that guesswork above.
But due to namespaces going funny sometimes, and possible newlines in HTML that we don't want, see the the line from the middle in the xsl:
Comment #4
teschek commentedI followed this instruction:
but when I do it grabs the file name rather than the html title field
So instead of
<xsl:value-of select="//title" />I tried
<xsl:value-of select="normalize-space(//xhtml:title)" />That seemed to work.
Comment #5
dman commentedThat'll work then!
Yeah, I can never remember when we need the xhtml: namespace or not. There were issues with different parsers and different input, which is why I ended up using name() everywhere.
I just couldn't find the XML function to set the default namespace on a doc. There is probably a proper answer now I don't have to think about PHP4 any more. I should revisit that and tidy things up.