• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

XSLT.TransForm method in C# :

Hi All,

My application takes in "Word 2003 XML" file name as an INPUT parameter and tries to APPLY XSLT file on this word 2003 document(xml) file and to extract the DATA ONLY entered by the user and puts into a file called as "out.xml".

The below is the code snippet.
The last statement in the code snippet is not working fine.
Can any body correct this and let me know.

 'Transform the Document / XML file into PURE XML DATA ONLY FILE
            ''Create a new XslTransform object.
            Dim xslt As New XslTransform

            ''''Load the stylesheet.
            xslt.Load(CType("c:\inetpub\wwwroot\Assessment\xsl\dataOnly.xslt", String))

            ''''Create a new XPathDocument and load the XML data to be transformed.
            Dim mydata As New XPathDocument("sample.xml")

            Dim resolver As XmlUrlResolver = New XmlUrlResolver
            resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

            ''''Transform the data and send the output to the console.
            xslt.Transform(SaveLocation, "c:\inetpub\wwwroot\Assessment\Templates\out.xml", resolver)
0
Wayne29
Asked:
Wayne29
  • 7
  • 6
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
Can you expand a little on "Not working fine" ?
0
 
Wayne29Author Commented:
Thanks Carl for your timely reponse.

"Not working fine", in the sense, the "out.xml" is coming EMPTY only with the ROOT TAG.
So for the timebeing I have used the below code to get "out.xml" only with the data.
But I do not want the below code to be in place as it is an additional overhead of loading Word Instance.
I would be very happy if my earlier approach (above) works!

So Basically what I am doing is, "Saving the file (doc/xml) which the user has given to me, by Applying XSLT"
to get PURE XML (data only). With this pure xml file, I am putting the values back to database. So next time he generates my template, he sees the latest values .....


Dim wordApp As Word.ApplicationClass
        Dim wordDoc As Word.DocumentClass

        Try
            wordApp = New Word.ApplicationClass
            wordDoc = New Word.DocumentClass
            wordApp.Visible = True

            wordDoc = wordApp.Documents.Open(tempfilename)
            ' x.Documents.Open(FileName:=tempfilename, ConfirmConversions:=False _
            ', ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
            'PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
            'WritePasswordTemplate:="", Format:=Word.WdOpenFormat.wdOpenFormatAuto, XMLTransform:="")

            wordDoc.Activate()

            With wordApp.ActiveDocument
                .XMLSaveDataOnly = False
                .XMLUseXSLTWhenSaving = True
                .XMLSaveThroughXSLT = _
                    "C:\inetpub\wwwroot\Assessment\xsl\dataOnly.xslt"
                .XMLHideNamespaces = False
                .XMLShowAdvancedErrors = True
                .XMLSchemaReferences.HideValidationErrors = False
                .XMLSchemaReferences.AutomaticValidation = True
                .XMLSchemaReferences.IgnoreMixedContent = False
                .XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = True
                .XMLSchemaReferences.ShowPlaceholderText = False
            End With
            wordApp.ActiveDocument.SaveAs(filename:="c:\inetpub\wwwroot\Assessment\Templates\out.xml", FileFormat:=Word.WdSaveFormat.wdFormatXML, _
            LockComments:=False, Password:="", AddToRecentFiles:=True, _
            WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
             SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
            False)


            wordDoc.Close()
            wordApp.Quit()
            wordApp = Nothing
            wordDoc = Nothing
        Catch ex As Exception
            Throw New Exception(ex.Message.ToString())
        Finally
            wordApp = Nothing
            wordDoc = Nothing
        End Try
0
 
Carl TawnSystems and Integration DeveloperCommented:
Can you post the starting section of the XML ? Its possibly a namespace issue in your document.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Wayne29Author Commented:
The below is the starting section of the XML file (word 2003 document saved as XML file)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><?mso-application progid="Word.Document"?>
<w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
0
 
Carl TawnSystems and Integration DeveloperCommented:
And have you catered for all the required namespaces in your XSL ?
0
 
Wayne29Author Commented:
I think you are about to catch it.
Please find below the complete XSLT file which extracts "DATA ONLY" for a given XML/DOC of Word 2003.
But I am not sure which namespace to be changed to meet my requirements.


<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"      
      exclude-result-prefixes="w v w10 sl aml wx xsl o dt st1"
      xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
      xmlns:v="urn:schemas-microsoft-com:vml"                  
      xmlns:w10="urn:schemas-microsoft-com:office:word"
      xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core"
      xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
      xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:o="urn:schemas-microsoft-com:office:office"
      xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
          xmlns:st1="urn:schemas-microsoft-com:office:smarttags">
      <xsl:output encoding="utf-8"/>
   
      <!-- root template -->
      <xsl:template match="/">
      <Assessment>
            <xsl:apply-templates select="w:wordDocument/w:body"/>
      </Assessment>
      </xsl:template>      

      <!-- outside of root XML element -->
      <xsl:template match="w:* | v:* | w10:* | sl:* | aml:* | wx:* | o:* | dt:* | st1:* | *[@w:st='on']">
            <xsl:apply-templates/>
      </xsl:template>
      <xsl:template match="*">
            <xsl:copy>
                  <xsl:copy-of select="@*"/>
                  <xsl:apply-templates mode="arbitraryXML"/>
            </xsl:copy>
      </xsl:template>
      <xsl:template match="text()"/>

      <!-- inside root XML element -->
      <xsl:template match="w:* | v:* | w10:* | sl:* | aml:* | wx:* | o:* | dt:* | st1:* | *[@w:st='on']" mode="arbitraryXML">
            <xsl:apply-templates mode="arbitraryXML"/>
      </xsl:template>
      <xsl:template match="*" mode="arbitraryXML">
            <xsl:copy>
                  <xsl:copy-of select="@*"/>
                  <xsl:apply-templates mode="arbitraryXML"/>
            </xsl:copy>
      </xsl:template>
      <xsl:template match="text()" mode="arbitraryXML"/>
      <xsl:template match="w:t" mode="arbitraryXML">
            <xsl:value-of select="."/>
      </xsl:template>      

      
</xsl:stylesheet>
0
 
Carl TawnSystems and Integration DeveloperCommented:
Do you have a more complete XML doc I could test against ?
0
 
Wayne29Author Commented:
Please find below the complete Word ML file of my document.
Thanks for your efforts.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><?mso-application progid="Word.Document"?><w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1" w:macrosPresent="no" w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve"><o:DocumentProperties><o:Title>Test Form</o:Title><o:Author>Wayne</o:Author><o:LastAuthor>Wayne F</o:LastAuthor><o:Revision>29</o:Revision><o:TotalTime>16</o:TotalTime><o:Created>2006-04-04T09:38:00Z</o:Created><o:LastSaved>2006-04-07T04:55:00Z</o:LastSaved><o:Pages>1</o:Pages><o:Words>70</o:Words><o:Characters>404</o:Characters><o:Company>RedFort Limited</o:Company><o:Lines>3</o:Lines><o:Paragraphs>1</o:Paragraphs><o:CharactersWithSpaces>473</o:CharactersWithSpaces><o:Version>11.5604</o:Version></o:DocumentProperties><w:fonts><w:defaultFonts w:ascii="Times New Roman" w:fareast="Times New Roman" w:h-ansi="Times New Roman" w:cs="Times New Roman" /></w:fonts><w:styles><w:versionOfBuiltInStylenames w:val="4" /><w:latentStyles w:defLockedState="off" w:latentStyleCount="156" /><w:style w:type="paragraph" w:default="on" w:styleId="Normal"><w:name w:val="Normal" /><w:rsid w:val="00DA6A64" /><w:rPr><wx:font wx:val="Times New Roman" /><w:sz w:val="24" /><w:sz-cs w:val="24" /><w:lang w:val="EN-GB" w:fareast="EN-US" w:bidi="AR-SA" /></w:rPr></w:style><w:style w:type="character" w:default="on" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font" /><w:semiHidden /></w:style><w:style w:type="table" w:default="on" w:styleId="TableNormal"><w:name w:val="Normal Table" /><wx:uiName wx:val="Table Normal" /><w:semiHidden /><w:rPr><wx:font wx:val="Times New Roman" /></w:rPr><w:tblPr><w:tblInd w:w="0" w:type="dxa" /><w:tblCellMar><w:top w:w="0" w:type="dxa" /><w:left w:w="108" w:type="dxa" /><w:bottom w:w="0" w:type="dxa" /><w:right w:w="108" w:type="dxa" /></w:tblCellMar></w:tblPr></w:style><w:style w:type="list" w:default="on" w:styleId="NoList"><w:name w:val="No List" /><w:semiHidden /></w:style><w:style w:type="table" w:styleId="TableGrid"><w:name w:val="Table Grid" /><w:basedOn w:val="TableNormal" /><w:rsid w:val="00DA6A64" /><w:rPr><wx:font wx:val="Times New Roman" /></w:rPr><w:tblPr><w:tblInd w:w="0" w:type="dxa" /><w:tblBorders><w:top w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto" /><w:left w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto" /><w:bottom w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto" /><w:right w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto" /><w:insideH w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto" /><w:insideV w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="auto" /></w:tblBorders><w:tblCellMar><w:top w:w="0" w:type="dxa" /><w:left w:w="108" w:type="dxa" /><w:bottom w:w="0" w:type="dxa" /><w:right w:w="108" w:type="dxa" /></w:tblCellMar></w:tblPr></w:style></w:styles><w:docPr><w:view w:val="print" /><w:zoom w:percent="100" /><w:doNotEmbedSystemFonts /><w:proofState w:spelling="clean" w:grammar="clean" /><w:attachedTemplate w:val="" /><w:documentProtection w:edit="forms" w:formatting="on" w:enforcement="off" /><w:defaultTabStop w:val="720" /><w:drawingGridHorizontalSpacing w:val="187" /><w:displayVerticalDrawingGridEvery w:val="2" /><w:punctuationKerning /><w:characterSpacingControl w:val="DontCompress" /><w:optimizeForBrowser /><w:validateAgainstSchema /><w:saveInvalidXML w:val="off" /><w:ignoreMixedContent w:val="off" /><w:alwaysShowPlaceholderText w:val="off" /><w:compat><w:breakWrappedTables /><w:snapToGridInCell /><w:wrapTextWithPunct /><w:useAsianBreakRules /><w:dontGrowAutofit /></w:compat></w:docPr><w:body><wx:sect><w:p /><w:p /><w:p /><w:p /><w:p><w:pPr><w:rPr><w:b /><w:u w:val="single" /></w:rPr></w:pPr><w:r><w:rPr><w:b /><w:u w:val="single" /></w:rPr><w:t>Test Form</w:t></w:r></w:p><w:p /><w:p><w:r><w:t>Title:</w:t></w:r><w:r><w:tab wx:wTab="285" wx:tlc="none" wx:cTlc="4" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="0" w:type="Word.Bookmark.Start" w:name="Title" /><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////2aAAAAAAAUAVABpAHQAbABlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AwAAAAIATQBy
AAMATQByAHMABABNAGkAcwBzAA==
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMDROPDOWN </w:instrText></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="0" w:type="Word.Bookmark.End" /><Title><w:r><w:t>Mrs.</w:t></w:r></Title></w:p><w:p /><w:p><w:r><w:t>Forename:</w:t></w:r><w:r><w:tab wx:wTab="480" wx:tlc="none" wx:cTlc="7" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="1" w:type="Word.Bookmark.Start" w:name="Text1" /><Forename><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAAMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>Mike</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r></Forename></w:p><w:p /><w:p><w:r><w:t>Surname:</w:t></w:r><w:r><w:tab wx:wTab="600" wx:tlc="none" wx:cTlc="9" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="2" w:type="Word.Bookmark.Start" w:name="Text2" /><Surname><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAAMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>Gatting Sir Mike Gatting</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r></Surname></w:p><w:p /><w:p /><w:p><w:pPr><w:rPr><w:b /><w:u w:val="single" /></w:rPr></w:pPr><w:r><w:rPr><w:b /><w:u w:val="single" /></w:rPr><w:t>Address</w:t></w:r></w:p><w:p><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /><w:t>Line 1:</w:t></w:r><w:r><w:tab wx:wTab="105" wx:tlc="none" wx:cTlc="1" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><Address1><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAAAAAAAAUAVABlAHgAdAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>54 Green Park</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="3" w:type="Word.Bookmark.End" /></Address1></w:p><w:p><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /><w:t>Line 2:</w:t></w:r><w:r><w:tab wx:wTab="105" wx:tlc="none" wx:cTlc="1" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><Address2><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAAAAAAAAUAVABlAHgAdAA5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>Balmoral Avenue</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="4" w:type="Word.Bookmark.End" /></Address2></w:p><w:p><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /><w:t>Line 3:</w:t></w:r><w:r><w:tab wx:wTab="105" wx:tlc="none" wx:cTlc="1" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><Address3><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAAAAAAAAYAVABlAHgAdAAxADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>Derry</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="5" w:type="Word.Bookmark.End" /></Address3></w:p><w:p><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /><w:t>Line 4:</w:t></w:r><w:r><w:tab wx:wTab="105" wx:tlc="none" wx:cTlc="1" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><Address4><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAAAAAAAAYAVABlAHgAdAAxADEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>Derry</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="6" w:type="Word.Bookmark.End" /></Address4></w:p><w:p><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /><w:t>Postcode:</w:t></w:r><w:r><w:tab wx:wTab="540" wx:tlc="none" wx:cTlc="8" /></w:r><aml:annotation aml:id="7" w:type="Word.Bookmark.Start" w:name="Text7" /><Postcode><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>DT2 3GH</w:t></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r></Postcode></w:p><w:p /><w:p /><w:p><w:r><w:t>Marital Status:</w:t></w:r><w:r><w:tab wx:wTab="135" wx:tlc="none" wx:cTlc="1" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="8" w:type="Word.Bookmark.Start" w:name="MaritalStatus" /><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////2bAAAAAAA0ATQBhAHIAaQB0AGEAbABTAHQAYQB0AHUAcwAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAD//wMAAAAHAE0AYQByAHIAaQBlAGQABgBTAGkAbgBnAGwAZQAIAEQAaQB2AG8AcgBjAGUA
ZAA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMDROPDOWN </w:instrText></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="8" w:type="Word.Bookmark.End" /><MaritalStatus><w:r><w:t>Divorced</w:t></w:r></MaritalStatus><w:r><w:t> </w:t></w:r></w:p><w:p /><w:p><w:r><w:t>Date of Birth</w:t></w:r><w:proofErr w:type="gramStart" /><w:r><w:t>:</w:t></w:r><w:r><w:tab wx:wTab="225" wx:tlc="none" wx:cTlc="3" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="9" w:type="Word.Bookmark.Start" w:name="Text4" /><DOB><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAQCgAAAAAAAAAAAAAACgBkAGQALwBNAE0ALwB5AHkAeQB5AAAAAAAAAAAAAAAAAAAAAAAA
AA==
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>25/12/1965</w:t></w:r><w:proofErr w:type="gramEnd" /><w:r><w:fldChar w:fldCharType="end" /></w:r></DOB><w:r><w:t> </w:t></w:r><w:proofErr w:type="spellStart" /><w:proofErr w:type="gramStart" /><w:r><w:t>dd/mm/yyyy</w:t></w:r><w:proofErr w:type="spellEnd" /><w:proofErr w:type="gramEnd" /></w:p><w:p /><w:p><w:r><w:t>Height</w:t></w:r><w:proofErr w:type="gramStart" /><w:r><w:t>:</w:t></w:r><w:r><w:tab wx:wTab="90" wx:tlc="none" wx:cTlc="1" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="10" w:type="Word.Bookmark.Start" w:name="Text5" /><Height><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAICgAAAAAAAAAAAAAABAAwAC4AMAAwAAAAAAAAAAAAAAAAAAAAAAAAAA==
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>1.65 M</w:t></w:r><w:proofErr w:type="gramEnd" /><w:r><w:fldChar w:fldCharType="end" /></w:r></Height><w:r><w:t> </w:t></w:r><w:proofErr w:type="gramStart" /><w:r><w:t>m</w:t></w:r><w:proofErr w:type="gramEnd" /></w:p><w:p /><w:p><w:r><w:t>Weight</w:t></w:r><w:proofErr w:type="gramStart" /><w:r><w:t>:</w:t></w:r><w:r><w:tab wx:wTab="30" wx:tlc="none" wx:cTlc="0" /></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="11" /></w:r><aml:annotation aml:id="11" w:type="Word.Bookmark.Start" w:name="Text6" /><Weight><w:r><w:t /></w:r><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////wAICgAAAAAAAAAAAAAABAAwAC4AMAAwAAAAAAAAAAAAAAAAAAAAAAAAAA==
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMTEXT </w:instrText></w:r><w:r><w:fldChar w:fldCharType="separate" /></w:r><w:r><w:rPr><w:noProof /></w:rPr><w:t>75.00 kg</w:t></w:r><w:proofErr w:type="gramEnd" /><w:r><w:fldChar w:fldCharType="end" /></w:r></Weight><w:r><w:t> </w:t></w:r><w:proofErr w:type="gramStart" /><w:r><w:t>kg</w:t></w:r><w:proofErr w:type="gramEnd" /></w:p><w:p /><w:p /><w:p><w:r><w:t>Admit to RABIU:</w:t></w:r><w:r><w:tab wx:wTab="555" wx:tlc="none" wx:cTlc="8" /></w:r><aml:annotation aml:id="12" w:type="Word.Bookmark.Start" w:name="AdmitToRABIU" /><w:r><w:fldChar w:fldCharType="begin"><w:fldData>/////2bAAAAAAAwAQQBkAG0AaQB0AFQAbwBSAEEAQgBJAFUAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAA//8CAAAAAwBZAGUAcwACAE4AbwA=
</w:fldData></w:fldChar></w:r><w:r><w:instrText> FORMDROPDOWN </w:instrText></w:r><w:r><w:fldChar w:fldCharType="end" /></w:r><aml:annotation aml:id="12" w:type="Word.Bookmark.End" /><AdmitToRABIU><w:r><w:t>Yes</w:t></w:r></AdmitToRABIU><w:r><w:t> </w:t></w:r></w:p><w:sectPr><w:pgSz w:w="11909" w:h="16834" w:code="9" /><w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="720" w:footer="720" w:gutter="0" /><w:cols w:space="720" /><w:docGrid w:line-pitch="360" /></w:sectPr></wx:sect></w:body></w:wordDocument>
0
 
Carl TawnSystems and Integration DeveloperCommented:
It works ok for me.

The only thing I changed in your code was to replace "SaveLocation" with the path to the source XML file. I'm not sure what "SaveLocation" refers to in your code, so maybe this is the cause of the problem.
0
 
Wayne29Author Commented:
Please find the entire code snippet of calling the same.
User has uploaded a file and i have saved it into SERVER in a predefined folder whose path is in "SaveLocation" variable.


Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        REM Upload File
        REM Update Database
        Dim blUpdate As Boolean
        Dim SaveLocation As String
        Dim objXSLT As New XslTransform
        Dim dSet As New DataSet
        Dim i, j As Integer

        Try
            If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then
                Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)

                SaveLocation = Server.MapPath("Templates") & "\" & fn.Replace("doc", "xml")

                Try
                    File1.PostedFile.SaveAs(SaveLocation)
                    Response.Write("The file has been uploaded.")
                Catch Exc As Exception
                    Response.Write("Error: " & Exc.Message)
                End Try
            Else
                Response.Write("Please select a file to upload.")
            End If

            'Transform the Document / XML file into PURE XML DATA ONLY FILE
            ''Create a new XslTransform object.
            Dim xslt As New XslTransform

            ''''Load the stylesheet.
            xslt.Load(CType("c:\inetpub\wwwroot\Assessment\xsl\dataOnly.xslt", String))

            ''''Create a new XPathDocument and load the XML data to be transformed.
            Dim mydata As New XPathDocument(SaveLocation)

            Dim resolver As XmlUrlResolver = New XmlUrlResolver
            resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

            ''''Transform the data and send the output to the console.
            xslt.Transform(SaveLocation, "c:\inetpub\wwwroot\Assessment\Templates\out.xml", resolver)

            'Read this XML and put data into dataset

            'SaveAsDataOnly(SaveLocation)

            'dSet.ReadXml("c:\inetpub\wwwroot\Assessment\Templates\out.xml", System.Data.XmlReadMode.Auto)
            'UpdateAssessmentDetails(dSet)

            'Response.Redirect("AssessmentHome.aspx", False)
        Catch ex As Exception
            Throw New Exception(ex.Message.ToString())
        End Try
    End Sub
0
 
Carl TawnSystems and Integration DeveloperCommented:
Have you stepped through with the debugger to check that the Xml and Xsl loaded ok ?  The actual transform itself appears to be ok in my sample app.
0
 
Wayne29Author Commented:
the out.xml is coming up with Root Tag so I don't think XSLT is not applied properly.
During debug all is fine.

My only worry is somehow XSLT file is not able to read through the rest of the NODES/MARKUPS in the template IN THIS APPROACH.
may be I need to carry on this issue.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Not really sure what to suggest next. Just in case you want to try it, this is my test app:

Imports System.Xml
Imports System.Xml.XPath
Imports System.Xml.Xsl

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Transform the Document / XML file into PURE XML DATA ONLY FILE
        ''Create a new XslTransform object.
        Dim xslt As New XslTransform

        Dim SaveLocation As String = "C:\Test.xml"

        ''''Load the stylesheet.
        xslt.Load(CType("c:\Test.xsl", String))

        ''''Create a new XPathDocument and load the XML data to be transformed.
        Dim mydata As New XPathDocument(SaveLocation)

        Dim resolver As XmlUrlResolver = New XmlUrlResolver
        resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

        ''''Transform the data and send the output to the console.
        xslt.Transform(SaveLocation, "c:\out.xml", resolver)

    End Sub

End Class

Which produces:

<?xml version="1.0" encoding="utf-8" ?>
<Assessment>
  <Title xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Mrs.</Title>
  <Forename xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Mike</Forename>
  <Surname xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Gatting Sir Mike Gatting</Surname>
  <Address1 xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">54 Green Park</Address1>
  <Address2 xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Balmoral Avenue</Address2>
  <Address3 xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Derry</Address3>
  <Address4 xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Derry</Address4>
  <Postcode xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">DT2 3GH</Postcode>
  <MaritalStatus xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Divorced</MaritalStatus>
  <DOB xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">25/12/1965</DOB>
  <Height xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">1.65 M</Height>
  <Weight xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">75.00 kg</Weight>
  <AdmitToRABIU xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:ns0="http://Greenpark.com/Namespace1">Yes</AdmitToRABIU>
  </Assessment>
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now