|
dnh wrote:
Do you have encoding in IE set to UTF-16 (or auto-select)? (View->Encoding ...)
Second, teo_xp wrote:
Response.charSet = "UTF-8"
dnh wrote:
Shouldn't there be UTF-16 instead?
About the first : i have auto-select.
About the second : You are right it has to be UTF-16 and in fact UTF-16 is what i currently use. The UTF-8 was wrong inserted from a previous test file i had.
|
|
|
|
|
hi again,
teo_xp wrote:
About the first : i have auto-select.
Out of curiosity, you tried to set it explicitly to UTF-16, did you? (I'll never ever belive IE)
I've googled a little and found this[^] so far (and your question in another forum).
Basicaly, there are tree points where encoding can go bad:
SQL DB-> recordset
recordset->XSLT transformed file
XSLT transformed file->browser
<code>
' rs is an ADO recordset filled with data from a sql Select statement <- UTF-16 (nvarchar from SQL)
styleFile = Server.MapPath(xslfile)
set stylexml =Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
stylexml.async = false
stylexml.load(styleFile)
set sourcexml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
sourcexml.async = false
rs.Save sourcexml,1 ' Save as adPersistXML <-UTF-8, see link below
set rs=Nothing
strPath=BuildPath(id,18)
dim xslty,xslProc
set xslt = Server.CreateObject("MSXML2.XSLTemplate")
xslt.stylesheet =stylexml
Set xslProc =xslt.createProcessor()
xslProc.input=sourcexml
xslProc.addParameter "Path",escape(strPath)
Response.charSet = "UTF-16"
xslProc.output = Response
xslProc.transform <- according to first link I gave u, u may try transformNodeToObject()
</code>
"A Recordset saved in XML format is saved using UTF-8 format. When such a file is loaded into an ADO Stream, the Stream object will not attempt to open a Recordset from the stream unless the Charset property of the stream is set to the appropriate value for UTF-8 format." (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthrstsave.asp[^])
Didn't that guy in other forum said it preserves your UTF-16?
I hope we moved on a little
[edit]
Do you have xml declaration WITH encoding, or at least meta tag with encoding in your resultant HTML file ?
[/edit]
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi , and thanks for your help
I am quite sure that the problem source is the ADO save method that outputs UTF-8.
The problem is that when i changes everything to UTF-8 (The asp that insert the data , the Response.charset , and the xsl file encoding ) i still have the problem and even more , doing view source the page i can't see the correct encoding as i can when i use UTF-16.
<small><b>dnh wrote:</b></small>
<i>Do you have xml declaration WITH encoding, or at least meta tag with encoding in your resultant HTML file ?</i>
I get this , that i think it's ok:
<META http-equiv="Content-Type" content="text/html; charset=utf-16">
Another dillema that i face is the format that i should save the xsl file using visual studio 6.
I have the following options : 1) Text file , 2) UTF-8 , 3) Unicode 4) Big-endian Unicode
Currently i am using the Unicode , but i've also try the Big-endian without any improvment.
finally , i have to say that i have try also the transformNodeToObject() method without success.
Anyway ,
Thanks again
|
|
|
|
|
Hi,
i am in a situation to get the XML out from an object in dotnet.
if i assign the values for the fields i am getting the nodes corresponding to the fields in the XML.
But i need to get the XML structure without asigning the values for the fields.(The XML struvture of the object).
How can i achieve this ?
Thanks in advance.
Sakthi
|
|
|
|
|
I create xml file to DataSet.WriteXml method. but xml file is null when table has not data in the database. Then create dataset from the xml file to DataSet.ReadXml method. I find out that dataset's tables is zerotable.how to do it that no data, table's struct still have?
|
|
|
|
|
If the SQLXMLCommand.text property is set to a stored procedure(or template) and the ExecuteStream method is called an exception is thrown whether or not it is processed on the server or the client. The exception is posted here:
<br />
Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80040E21.<br />
<br />
Source Error: <br />
<br />
Line 36: 'sxcmd.RootTag = "FullName"<br />
Line 37: Dim MemSt As MemoryStream<br />
Line 38: MemSt = sxcmd.ExecuteStream()--->error occuring here<br />
Line 39: Response.Write(MemSt.Length)<br />
Line 40: Dim strRdr As New StreamReader(MemSt<br />
After much searching, try to find what HRESULT:0X800040E21 is, and you will be surprised as to what I found. It says that an error occured . How much more user friendly message do you want?
|
|
|
|
|
maybe a stupid question, bt is that stored procedure ok?
I mean does it really return XML? (contains FOR XML modifier)
If not, take a look at this[^]
mysorian wrote:
How much more user friendly message do you want?
ah. It's COM. You can expect everything from COM but not being user friendly
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi David:
Nothing is stupid, everything needs an explanation. Thanks for the link to the article, but it is not using the ExecuteStream method.
sincerely,
mysorian
ah! too many things under the hood
|
|
|
|
|
mysorian wrote:
Nothing is stupid
So, how'd you call somebody who produced 53MB (!) ASPX web form due to buggy XSLT? (jup, I have my day!)
So, does it mean that SP doesn't return XML? I basically told you to look at that link only IF it isn't ok
mysorian wrote:
but it is not using the ExecuteStream method.
No it's not, bt it shows you how to make SP produce XML results. Btw I think you use ExecuteStream right way.
You can use ad-hoc SQL statements or you can also execute stored procedures that return XML. Consider the following stored procedure:
CREATE PROCEDURE dbo.GetEmployeesXml
AS
SELECT * FROM employees FOR XML AUTO
RETURN
This can be executed as follows:
SqlXmlCommand cmd = new SqlXmlCommand(NorthwindConnString);
cmd.RootTag = "Employees";
cmd.CommandText = "EXEC GetEmployeesXML";
XmlReader xr = cmd.ExecuteXmlReader();
I suspect ExecuteStream() fails because SP return non-XML data (some table or something like that).
If you can, try ExecuteReader() (and XmlReader instead of stream). That way you can be sure if problem is in SP or somewhere else. (If it fails than problem is probably in SP)
mysorian wrote:
ah! too many things under the hood
Is that your sig or do you say this to me?
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
David:
There is more to it than meets the eye...
-------------
PROCEDURE dbo.GetEmployeesXml<br />
AS<br />
SELECT * FROM employees FOR XML AUTO<br />
RETURN
------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
'Put user code to initialize the page here<br />
If Not IsPostBack Then<br />
Dim sxcmd = New SqlXmlCommand("PROVIDER=SQLOLEDB.1;SERVER=XPHTEK;DATABASE=Northwind;INTEGRATED SECURITY=sspi;")<br />
sxcmd.RootTag = "Employees"<br />
sxcmd.CommandText = "EXEC GetEmployeesXml"<br />
Dim xrdr As System.Xml.XmlReader<br />
<br />
xrdr = sxcmd.ExecuteXmlReader()<br />
Response.Write(xrdr.HasValue)<br />
<br />
End If<br />
End Sub
----------------------------
Exception Details: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80040E21.<br />
<br />
Source Error: <br />
Line 32: Dim xrdr As System.Xml.XmlReader<br />
Line 33: <br />
Line 34: xrdr = sxcmd.ExecuteXmlReader()--->error generted here<br />
Line 35: Response.Write(xrdr.HasValue)<br />
Line 36: While xrdr.Read
-----------------------
Now I substitute the 'stored procedure' by the statement used in the procedure, voila! No exception thrown.
|
|
|
|
|
Hi, I am trying to use MSXML to parse an XML document. I have a document that has several special characters such as é à and others ( accents used in latin derived languages like french and spanish ).
When MSXML encounter such a character it gives an error message saying : An invalid character was found in text content.
I can remove all the accents either by hand or programmaticly but the thing is I need to conserve them. I am using data from the XML and if the data is not accented it can be confusing and be seen as spelling mistakes.
Is there a way to have MSXML read a document which contains accentuated characters and for it to store that data correctly ?
EDIT : I tried putting at the start of the XML document but I still have this error.
|
|
|
|
|
Are you using appropriate encoding? Sounds like problem is here. UTF-8 is default encoding for XML. However, I am not sure what is default encoding for MSXML parser. (is it that one in IE? I don't trust anything around IE)
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Yes MSXML is the one from IE, unfortuntly I must use it.
I tried not specifying an encoding in my file and specifying UTF-8 in my file but to no effect. I don't know if I can specify it from the parser.
|
|
|
|
|
Ok I have found it I must specify ISO-8859-1 encoding at the start of the file like this : <?xml version="1.0" encoding="ISO-8859-1"?>
EDIT : Change the comment formating because the XML tag would not show up.
|
|
|
|
|
Anonymous wrote:
unfortuntly I must use it.
That says everything!
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
I’ve got a problem, I’m hoping someone out there has the answer to. I am a .Net programmer working for a small educational software company. I need to add some simple reporting to the project I am working on. Basically, I need to take some data from my database and format a RTF document from it that can then be displayed in a rich text box or printed or saved or whatever. Unfortunately RTF code is not so easy to understand.
I was told by someone that I could use XSLT to do this. After some reading I found out that this is not exactly correct. You can use XSLT, however you still need to be able to write RTF code. I could use XSL-FO, but since .Net does not implement XSL-FO, I would need to use a third party tool in order to transform my XML data and XSLT stylesheet to RTF. My company doesn’t want to pay for one of these third party tools, nor do they want to deal with any complex licensing issues, that come along with them.
Does anyone have any suggestions on how I can accomplish this task? The reports are not complex, just some simple text formatting and tables.
Thanks for your help
|
|
|
|
|
Hi David. Would an HTML format be acceptable for your reports? I'm seeing more and more reporting modules producing HTML output that in the past would have been .rtf, and the code to launch an .html report in the default browser is simple.
|
|
|
|
|
HTML would be ok. If it could look the same on the screen as it would on printed paper. Also, I would have to learn HTML, which I thankfully have been able to avoid up to this point. Can HTML do tables and margins and such? Forgive my ignorance.
Also, the end users of the application's reporting feature will be school teachers, who aren’t known for being very computer savvy. If I use the default browser to open and view reports, I’ll get thousands of tech support calls because a teacher has lost the browser window behind the application window. It’s hard to explain the concept of “[Alt]+[Tab]” to school teachers. The application hides the task bar so that kids aren’t messing with it instead of using the application.
If I were to use HTML, I would have to use one of those browser window controls on a form in order to prevent the “[Alt]+[Tab]” problem.
Thanks
|
|
|
|
|
hi,
david@mindplay.com wrote:
Also, I would have to learn HTML, which I thankfully have been able to avoid up to this point.
thankfully? hmmm. HTML is nice. CSS is cool. XML is almost perfect.
(yes I am web developer )
david@mindplay.com wrote:
Can HTML do tables and margins and such? Forgive my ignorance.
Even more. With use of CSS, you have lot of freedom in appereance.
david@mindplay.com wrote:
If I use the default browser to open and view reports, I’ll get thousands of tech support calls because a teacher has lost the browser window behind the application window.
hmm. .NET can use Microsoft WebBrowser control - Using the WebBrowser control in .NET Article[^]
And .NET Framework 2.0 has native WebBrowser control for .NET
After quick search, there are some tutorial on HTML & related stuff:
HTML Guide article[^]
CSS For Beginners article[^]
W3C - My favourite Web standard organization[^]
And W3C Schools, great tutorials for web (recommended)[^]
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
I would need the end product to be one single file, so that it can be saved or emailed. If I use XSLT to transform my data into HTML then it would be one file. I don't know much about CSS. Can I use CSS to create an HTML file or would I essentially have two files my XML and my CSS?
Thanks
|
|
|
|
|
hi again
if you need one file, you can use inline CSS. CSS if for formatting HTML, you can write (generate with XSLT) it inside your html file.
Example:
(bold part is inline CSS)
HTML Source:
<code>
<h1 style="color:red">HTML heading 1, coloured to red using css</h1>
</code>
result:
HTML heading 1, coloured to red using css
Got the idea?
much cleaner way is to have css classes (you can define them in external .css file, bt you can do it in style element):
<style>
.red {color:red}
</style>
Use is similar:
<h1 class="red"></h1>
(it gives exctly same result as first example - benfit is that you can reuse defined class many times, and also that CSS effects may overlap - that's why they call it Cascading Style Sheet)
Hope I gave you some ideas. This is only tip of the iceberg! :->
one more note - with css you can nicely control printing
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
I see, thank you. I'm reading about CSS right now.
Dave
|
|
|
|
|
Hi,
I have a XML string. I want to load it to Multiple tables using visual basic. How do I do that?
Thanks
|
|
|
|
|
I have implemented WSE security on my .net web service and would like to know how to make a request to the service using perl-lite or Java. Can someone point me to an article that explains how this can be done? Thank you,
Jason W.
|
|
|
|
|
I have to develop a tool which will consist of questionnaires and the user has to rate every category. I have to use XML as data source and the changes made will be stored in the XML file.
I am using a tree view on the left side of the form to display the categories present in the XML file. I want to have details of that category and the questions to be displayed on the right side on clicking any of the node of the tree. Since, the questions will be different for each node present in the tree, can someone suggest me any way to achieve this. I think using a dataset for changing the questions on click of a tree view node will be an option.
can anyone help me with the code. I am struggling frm past 3 and half weeks.
Thanks again.
|
|
|
|