Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Why would encoding="UTF-8" chance to "UTF=16"?

From: "Hennie" <ze1@--------.--->
To: NULL
Date: 7/20/2007 1:39:00 PM

Good,

Here is one of the code I am using to transform the file.  The other one 
also use MSXML.DOMDocument and I have tried both.  I found both on the 
Internet.

I hope this helps.

Thank you.

Hennie


Sub xml4()

Dim xmlSource

Dim xmlXForm

Dim strErr

Dim strResult



Dim fso, file

Dim strPath

Const ForWriting = 2



Set xmlSource = CreateObject("MSXML.DOMDocument")

Set xmlXForm = CreateObject("MSXML.DOMDocument")



xmlSource.validateOnParse = True

xmlXForm.validateOnParse = True

xmlSource.async = False

xmlXForm.async = False



'initializing, and creating the objects to load our XML and XSL files needed 
in the next step:





' This loads the text that I want to transform

xmlSource.Load "H:\Chem\DATA\XML Report\sample.xml"





If Err.Number <> 0 Then

strErr = Err.Description & vbCrLf

strErr = strErr & xmlSource.parseError.reason & " line: " & _

xmlSource.parseError.Line & " col: " & _

xmlSource.parseError.linepos & _

" text: " & xmlSource.parseError.srcText

MsgBox strErr, vbCritical, "Error loading the XML"



End If



' This loads the XSLT transform

'Here you need to update your Xsl file



'xmlXForm.Load "Your XSL file Path"

' This loads the XSLT transform

xmlXForm.Load "H:\Chem\DATA\XML Report\mews.xsl"

If Err.Number <> 0 Then



strErr = Err.Description & vbCrLf

strErr = strErr & xmlSource.parseError.reason & " line: " & _

xmlSource.parseError.Line & " col: " & _

xmlSource.parseError.linepos & _

" text: " & xmlSource.parseError.srcText

MsgBox strErr, vbCritical, "Error loading the Transform"

End If



'This tells the XML objects to load the files into memory for the transform 
which we perform next:



' This transforms the data in xmlSource

strResult = xmlSource.transformNode(xmlXForm)



If Err.Number <> 0 Then



strErr = Err.Description & vbCrLf



strErr = strErr & xmlSource.parseError.reason & _

" line: " & xmlSource.parseError.Line & _

" col: " & xmlSource.parseError.linepos & _

" text: " & xmlSource.parseError.srcText



MsgBox strErr, vbCritical, "Error executing the Transform"



End If



'At this point, the transformed XML is placed into a string variable called 
strResult that we need to write as file to disk:





Set fso = CreateObject("Scripting.FileSystemObject")



'Here you need to update your Output files

strPath = "H:\Chem\DATA\XML Report\result.xml"



' open the file

Set file = fso.opentextfile(strPath, ForWriting, True)



' write the info to the file

file.Write strResult





End Sub

"Anthony Jones" <Ant@y...> wrote in message 
news:eAxlfSEyHHA.484@T......
>
>
> "Hennie" <ze1@h...> wrote in message
> news:u%Tmi.39242$KV1.23035@r......
>>
>>
>> Good Day,
>> I have the XSL style sheet attached below.  Whenever I do a 
>> transformation
>> of an XML file the "UTF= 8" enconding is always changed to "UTF = 16".
>> Before I can use the transformed file I need to Edit it in Notepad.  The
>> rest of the transformed file works as a charm.  I assume it is something
>> small but I know to little to solve the problem.
>>
>> Thank you for your time.
>>
>> Hennie
>>
>>
>> <xsl:stylesheet
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
>>
>>    <xsl:output method="xml" indent="yes"/>
>>
>>  <!-- the key determines (here) what to group by -->
>>    <xsl:key name="sample" match="sample" use="concat(sample_date_time,
>> cp_name, imis_cp_ext, dischg_sample_cd, sample_comment)" />
>>
>>  <xsl:template match="/">
>>        <submission imis_company_code="0001843309" ws_name="ONTARIO POWER
>> GENERATION INC. -  LENNOX GS">
>>            <xsl:apply-templates />
>>        </submission>
>>
>>  </xsl:template>
>>    <xsl:template match="dataroot">
>>        <!-- the actual 'group by' construct -->
>>         <xsl:for-each select="sample[generate-id() =
>> generate-id(key('sample',concat(sample_date_time, cp_name, imis_cp_ext,
>> dischg_sample_cd, sample_comment))[1])]">
>>            <xsl:copy>
>>                <!-- date-time must become an attribute -->
>>                <xsl:apply-templates select="sample_date_time | cp_name |
>> imis_cp_ext | dischg_sample_cd | sample_comment"/>
>>
>>   <!-- find all samples with equal date time -->
>>                <xsl:apply-templates select="key('sample',
>> concat(sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd,
>> sample_comment))" />
>>            </xsl:copy>
>>        </xsl:for-each>
>>    </xsl:template>
>>    <!-- match the sample's that are grouped -->
>>    <xsl:template match="sample">
>>        <result>
>>
>>   <xsl:apply-templates select="*[not(self::sample_date_time or
> self::cp_name
>> or self::imis_cp_ext or self::dischg_sample_cd or self::sample_comment)]"
>> />
>>
>>        </result>
>>    </xsl:template>
>>
>>    <!-- any direct child of 'sample' must be turned into an attribute -->
>>    <xsl:template match="sample/*">
>>        <xsl:attribute name="{name()}">
>>            <xsl:value-of select="."/>
>>        </xsl:attribute>
>>    </xsl:template>
>>
>>
>
> It might be more helpful if you post the code that executes and saves the
> transforms results.
>
> -- 
> Anthony Jones - MVP ASP/ASP.NET
>
> 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent