|
I assume that you are using one of the MSXML implementations. To set the encoding see the xsl:output transformation element (at the begining of the transformation), You should be able to set utf-8 with it. UTF-16 is a valid encoding. Most of my work right now is with the Apache line of implementations so there may be some variations. I have shown that DOM and SAX transformations do not always give the same results. I do have some test applications with the MSXML v3 and v4 so I can do some experiments if needed.
<xsl:output method="text" encoding="utf-8"/>
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
I am using the MSXSL that comes with IE6 or the .NET Runtime, whichever is newer (I have both installed).
So XSL will generate an <?xml...?> declaration automagically, which can be controlled by the <xsl:output> element?
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
I can say that the xml declaration is not allways output. With the output line shown earlier it should never be output. Just add it with the xsl:text line if needed. The output line will set if encoding is utf-8.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
So, my XSL should like like this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0">
<xsl:output encoding="utf-8" />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</xsl:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<!-- Stuff here -->
</html>
</xsl:template>
</xsl:stylesheet>
And this will output:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<!-- The stuff that was where the comment was goes here -->
</html>
If you're not absolutely sure, could you write me quick program or give me the JScript code (not .NET) to just output the text? Whenever I do a view source in IE, it just gives me the original XML.
I would do that myself, but I'm stuck on this Windows 98 until I get a new hard drive
Thank you!
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
There are two ways to output the DOCTYPE.
One is using the OUTPUT method in XSL, like so:
>xsl:output method="html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="DTD/xhtml1-transitional.dtd" indent="yes" /<
The other, is easier but probably not such a good idea. It uses the XSL:TEXT and CDATA section methods:
>xsl:text disable-output-escaping="yes"<>![CDATA[>!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"<]]<>/xsl:text<
This one also baffled me for awhile until I found the OUTPUt method, happy hunting.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
|
|
|
|
|
Paul,
Nice to see you back. I hope this is not temporary.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
Thanks Michael, it is semi-temporary. I have not been off of CP voluntarily, but rather I have been at the mercy of my internet connection which deems CP an unforgivingly slow site.
However our new line should be in within the week and I shall be back next week.
I miss the place
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
|
|
|
|
|
The output works GREAT for the !DOCTYPE, and is much preferable to the method I got from above (enclosing it in a <xsl:text disable-output-escaping="yes"> section)
But... I'm still stuck on getting my <?xml...?> into the output, as I am really trying to output XHTML, not HTML as the above <xsl:output> you posted says (and all good XHTML has a <?xml...?> declaration, as it is XML).
Will this automagically appear, with the encoding specified in the <xsl:output> tag? Or do I have to put it in a <xsl:text disable-output-escaping="yes"> tag?
Again, I could figure this all out myself without bugging everyone if someone would just write a program that takes in.xml, and using transform.xsl outputs out.xsl. That's all I need! I have one that is supposed to do this called XSL Tester, but it's rather screwy (always outputting a <?xml version="1.0" encoding="UTF-16"?> at the top, no matter what I do with output or text tags.), and doesn't use the .NET version of MSXML so I'm never sure if that's really what's going to happen. Heck, I could send you the source code if you would compile it!
Thank you for your time and help,
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
Actually, now I have a working solution, but I'm getting the idea it's bad practice, and wanted to know if it is.
I enclose EVERYTHING in a:
<xsl:text>
<!CDATA[[
<!-- There's a bunch of XHTML here,
including the xml processing instruction and the
DOCTYPE, but it's parsed as simply text. Is
this good practice? Because it's convenient! -->
]]>
</xsl:text>
section. It works, and it's very convienient. Whenever I want to output something using template rules, I simply end if with a ]]></xsl:text> , write the xsl element, then restart it with the <xsl:text><!CDATA[[ . But... this just seems kind of wrong... but it works... but it seems wrong... but... so, what do you think?
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|
|
Domenic [Geekn] wrote:
But... this just seems kind of wrong... but it works... but it seems wrong... but... so, what do you think?
It works, just like using pantyhose to fix a broken fan-belt in a car works. However as soon as you can you should get a new proper fan-belt, right?
I had a crushing deadline which forced me to use the xsl:text method to output the DOCTYPE.
However what happened was that when a third party tried to programatically query my XSL documents to gather some info for an integration project they failed to get the DOCTYPE. I eventually re-coded my XSL docs to use the output method.
So the answer is; Yes it works but don't do it if you can avoid it. Your XSL docs will be technically better and easier to maintain in the future if you use the proper output method.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
"Reports of my death have been greatly exaggerated."
|
|
|
|
|
Hi there, anybody using Microsoft Sharepoint Portal? If any one know how to customize the sharepoint enviroment or where to get more web part, please help me! Thanks all.
Tho
|
|
|
|
|
Go to the Microsoft site and search for Sharepoint. You'll find plenty of information there.
You can get a bunch of web parts here.
|
|
|
|
|
Thanks a lots, MarSCoZa! It is really helpful, do u know how to set the SMTP
setting to use the email notification feature in Sharepoint? How to made it automatically send email to approver after document have been published.
Thanks !
regards, Tho
|
|
|
|
|
I haven't worked very intensively with Sharepoint, but from the User's help it seems you have to do the following:
1) In Windows Explorer, expand your workspace (under My Network Places)
2) Right-click on the Documents folder and select Properties
3) Select the Approval tab, and fill in the details
|
|
|
|
|
Hi all,
I'm having problems displaying a '&' in an XML tag.
<senderaccname>dssdsd&sdsdsd
When I run this on a XSL Stylesheet, I get the following error:
Ein Semikolon wurde erwartet. Fehler beim Bearbeiten der Ressource 'file:///C:/WINNT/SM.XML'. Zeile 33, Position 29
Semicolon expected. Are there any special handlings for characters like these?
Thx
Stefan
|
|
|
|
|
Try & or & if you want to show an & character in your output.
|
|
|
|
|
MarSCoZa wrote:
Try & or & if you want to show an & character in your output.
Hi,
thanks for your answer. Could you please provide all sequences for all the five special characters (I think its five) because I don't know where to look for on the web.
Thx a lot!
Stefan
|
|
|
|
|
|
You might want to take a look at the W3C's Blueberry spec on character sets in XML.
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
I have some code I wrote ages ago, and now it won't run on my machine at work ( but it runs on everyone elses ). I have IE6 and we've found conversely that ome of my XSL *only* ran on my machine. The problem is when I have a list of nodes, all siblings, and I loop through them and use appendChild to cut and paste them into another document. It simply blows up. Any suggestions ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I'm testing this and not having any problems. Can you post some sample code?
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
I'll get it from work tomorrow. Basically it works on other machines but not on mine, and I *think* IE6 may have an influence. The thing is, the block of code that fails I wrote some code to look the same, and it worked. I worked late on Tuesday and I spent from 5 to 10:30 on this, then three more hours the next day and we dropped it in the end simply because it's only my machine that won't run it. Which means I can't run a central piece of code for the project, which I wrote.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
You have check the xml parser versions are the same correct?
|
|
|
|
|
We've installed the latest version of MSXML on all machines, but I believe that IE6 changes something in that regard.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
OH!, this one looks like it could be related to a question i just posted in the ASP forum.
Our problem is that HTML being parsed perfectly well in IE5 suddenly seems to miss items in listboxes when parsed by IE6.
As i am currently doing some consulting away from our home office i am not able to view the source, but if my co-workers are still using my scripts then those list boxes are filled dynamically by traversing nodes in the DOM.
If we could get this behaviour cathegorized as a genuine bug and not 'a new IE feature', then we could tell our customers to use IE5 while waiting for the next patch.
"It could have been worse, it could have been ME!"
|
|
|
|