473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XSLT HTML Validation

I am producing HTML from XslTransform (C#) and the HTML does not
validate, see http://www.redburg.co.uk/mira/mira415_ev_wh_ch.html as
an example.

I am using the following XSLT code:

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

<xsl:output method="html" version="4.01"/>
<xsl:output doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
<xsl:output doctype-public="-//W3C//DTD HTML 4.01//EN"/>

Are there any URL's giving more details on xsl and html and how the
HTML can validate after being created from XslTransform.
Nov 12 '05 #1
12 5631
Trevor Oakley wrote:
I am producing HTML from XslTransform (C#) and the HTML does not
validate, see http://www.redburg.co.uk/mira/mira415_ev_wh_ch.html as
an example.


What do you mean "does not validate" ? Basically in XSLT resulting
document never gets validated, it's stylesheet author's responsibility
to output valid result.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

I am referring to W3C validation of HTML. My output from the XML/XSLT is
HTML but the doctype is absent which causes a failed validation.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3
Trevor Oakley wrote:
I am referring to W3C validation of HTML. My output from the XML/XSLT is
HTML but the doctype is absent which causes a failed validation.


Aha. Most likely the problem has something to do with how you run the
transformation in your C# code. Make sure you don't transform to
XmlWriter or XmlReader, because as stated at MSDN, xsl:output
instruction is ignored in such case.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4
My code is below. The error appears to originate from a failure to
detect encoding data by the HTML validator and it "assumes" UTF8 and
also any doctype data. I need UTF8 encoding to get the "£" working.
thisStream.Position = 0;
string xslPath = Server.MapPath("XSLName.xsl");
string htmlPath = Server.MapPath(HTMLName);

XPathDocument aXPathDocument = new XPathDocument(thisStream);
XslTransform transform = new XslTransform();

transform.Load(xslPath, resolver);
XmlTextWriter aWriter = new XmlTextWriter(htmlPath, Encoding.UTF8);

aWriter.Formatting = Formatting.Indented;
aWriter.Indentation=4;
transform.Transform(aXPathDocument,null,aWriter, resolver);
aWriter.Flush();
aWriter.Close();


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
Trevor Oakley wrote:
My code is below. The error appears to originate from a failure to
detect encoding data by the HTML validator and it "assumes" UTF8 and
also any doctype data. I need UTF8 encoding to get the "£" working.


I wrote to you in prev mail:

Make sure you don't transform to XmlWriter or XmlReader, because as
stated at MSDN, xsl:output instruction is ignored in such case.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #6
My transform is using XmlTextWriter not XmlWriter.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #7
use StreamWriter instead:
StreamWriter aWriter = new StreamWriter(htmlPath)
transform.Transform(aXPathDocument,null,aWriter, resolver);

"Trevor Oakley" <sa***@trevoroakley.com> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl...
My transform is using XmlTextWriter not XmlWriter.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #8
I had already got it working with StreamWriter, but my implementation
wrote the XslTransform to a MemoryStream and then to a file via
StreamWriter.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #9
Trevor Oakley wrote:
My transform is using XmlTextWriter not XmlWriter.


Hehe, XmlTextWriter is an implementation of XmlWriter.
Use StreamWriter instead.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #10
Trevor Oakley wrote:
I had already got it working with StreamWriter, but my implementation
wrote the XslTransform to a MemoryStream and then to a file via
StreamWriter.


Why not directly to a file? That's pure waste of memory to have interim
MemoryStream here.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #11
I assume XmlTextWriter has different methods and properties so it does
not follow that if XmlWriter fails to use xsl:output tags then
XmlTextWriter will also.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #12
Trevor Oakley wrote:
I assume XmlTextWriter has different methods and properties so it does
not follow that if XmlWriter fails to use xsl:output tags then
XmlTextWriter will also.


XmlWriter is abstract class. XmlTextWriter is one of implementations.
xsl:output instruction is ignored by design, when transformation is done
to any XmlWriter implementation.
You should also realize that you never output HTML when transforming to
any XmlWriter, because XmlWriter writes well-formed XML by definition
and by design.
--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
8
by: goldtech | last post by:
Newbie esp about html validation - seems like something to strive for. Yet many pages even "enterprise" corporate type pages do not validate, yet seem to display well on most browsers. Two...
10
by: NikitaTheSpider | last post by:
Hi all, I would like to announce the alpha release of a service that does bulk/batch HTML validation, link checking and more. During alpha testing, the service is free -- I need people to try this...
1
by: Tatyana | last post by:
Hi All, I have a question regarding validation with XHTML on ASP.Net websites. Our site is built on ASP.NET 2.0 with validation XHTML. Search Engine Optimizer advised us that we should change it...
1
by: =?Utf-8?B?ZGlzY2lwbGluZTRldmVyNjY2?= | last post by:
Hi, the CMS out company wrote a few years ago, uses certain attrbutes not included in any HTML validation known. Is there a way to add these custom attributes to HTML validation within VS2005? I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.