I'm trying to learn how to use XSLT to read from one HTML source and create a new HTML page. I know some about using XSLT to read from a XML file and create a new HTML page, but the other way is new for me and I can't find any useful tutorials about the subject.
I'm loking for some basic knowledge about this to be able to start, but I don't know how to think and use XSLT to e.g select divs and it's content from the source HTML and create a new HTML and perhaps create a new page without the head tag and so on.
Preciate some basic help or a good links about this subject. Thanks! :)
Hi again! This is my task and problem that I need some help to solve, if it's possible?! I have one XHTML document that use a CSS stylesheet. Let's call the XHTML document for "B". I want to create a new XHTML document, let's call that "A", and use some of the divs from "B" on "A" with a new CSS stylesheet. It's like if someone click on "B" they would come to "A" instead. Hmmm, and I don't know where to start and I don't know if this is possible? How do I add a CSS stylesheet to the XSLT code? Maybe no one understand what I'm talking about, but don't hesitate to ask. Preciate all help that I can get to solve this task! Thanks in advance! :)
When converting from XHTML to (X)HTML, from the point of view of a processor, you might want first to avoid the external resolution of the parse phase caused by the doctype, as it can be source of runtime errors.
In such a case you should see if your processor supports any options to disable that or you may need to remove the doctype declaration from the input document directly.
For example in msxsl you can use the
xe
options to disable external doctype resolutions:From the point of view of XSLT 1.0, your xhtml is just an XML document with a specific namespace. For instance:
To be able to convert this to other XHTML document your XSLT must:
You will access the elements in the input document using the defined prefix. For example this transform just add an header to the input document:
Notice:
xmlns:x="http://www.w3.org/1999/xhtml"
allows you to correctly select the elements in the input document which are qualified in the xhtml namespace.xmlns="http://www.w3.org/1999/html"
prevents the generation of unwanted empty namespacesxmlns=""
in the output document.exclude-result-prefixes
allows you to exclude the declaration of the xhtml namespace in the output document elements explicitely declared in the XSLT.From the point of view of XSLT 2.0, it's really much simple. You can declare the XPath default namespace, thus getting rid of the prefixes. The stylesheet declaration will be:
welcome to Stackoverflow!
You may in in one of two situations: