Presentation on theme: "1 The MITRE Using XSL to Generate XHTML Documents Roger L. Costello XML Technologies."— Presentation transcript:
1 The MITRE Corporation @JICPAC Using XSL to Generate XHTML Documents Roger L. Costello XML Technologies
2 The MITRE Corporation @JICPAC What is XHTML? With HTML you can –omit end tags, –use upper case for the start tag and then lower case for the end tag (i.e., HTML if case insensitive –leave off the quotes around attribute values Clearly, these all violate XML XHTML is HTML that follows all the rules of XML
3 The MITRE Corporation @JICPAC HTML: XHTML: Most browsers today do not understand empty elements, e.g.,. Consequently, we must "trick" the browser. You can put a class attribute on just about any HTML element. The class attribute can have any value. So, we use the class attribute simply to get the browser to "see" this element as a break element.
4 The MITRE Corporation @JICPAC … HTML: XHTML: XHTML specifies that all tags be in lower case.
5 The MITRE Corporation @JICPAC HTML: XHTML: Quote the attribute value!
6 The MITRE Corporation @JICPAC HTML: XHTML: 1. Add a DOCTYPE declaration with a PUBLIC identifier 2. Add a namespace declaration to the root element.
7 The MITRE Corporation @JICPAC Advantages of formatting your HTML as XHTML Ever notice how some web sites are broken when viewed in Netscape, but work when viewed in IE (or vice-versa)? –That's oftentimes because the HTML has missing end tags and one browser is able to "fix it" while the other isn't If it were written in XHTML then there would never be a problem with missing end tags Many web masters will check their HTML by testing it against as many browsers as they can –There are many, many browsers, and many versions of browsers, so exhaustive testing is very difficult If it were written in XHTML then it could be tested simply by validating against the XHTML DTD Due to the relative randomness of HTML it is very difficult for applications such as screen scrapers to make use of it. –With XHTML the document is much more strictly organized and hence it is easier to parse and make use of it.
8 The MITRE Corporation @JICPAC Generating XHTML with your stylesheet Welcome Welcome! This default namespace declaration will generate an identical default namespace declaration in the output These instruct the XSL Processor to create a DOCTYPE declaration in the output, with a PUBLIC identifier as well as a SYSTEM identifier. (see html-example25)
9 The MITRE Corporation @JICPAC Here's what will be generated Welcome Welcome! Notes: 1. There is no XML declaration 2. There is a DOCTYPE declaration containing a PUBLIC identifier as well as a SYSTEM identifier 3. There is a default namespace declaration 4. We can validate this XHTML document
Your consent to our cookies if you continue to use this website.