Solved

Namespace prefix 'xsl' is not defined

Posted on 2009-03-29
5
2,257 Views
Last Modified: 2013-11-26
Hi,
I'm having tons of error message "Namespace prefix 'xsl' is not defined". I'm quite sure that i stuffed up something but i can't seem to find it.

Help please!

Anyway, what i'm trying to do is convert/transform the output from SQL Server 2000 to a XML which is formatted/indented by using System.Xml.Xsl.XslCompiledTransform(). See my code below...

   Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Using conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("SMI_CENTRISConnectionString").ConnectionString)
            Dim cmd As New Data.SqlClient.SqlCommand("SMI_P001_XML_Download_Test", conn)
            cmd.CommandType = Data.CommandType.StoredProcedure
            conn.Open()
            Dim da As New Data.SqlClient.SqlDataAdapter(cmd)
            Dim ds As New Data.DataSet
            da.Fill(ds)
            Dim nowString As String = Now.ToString("dd-MM-yyyy hh.mm.ss")
            Dim fileName As String = "D:\TEMP\SMI_Student_Transfer_" & nowString & ".xml"
            Dim doc As System.Xml.XmlDataDocument = New System.Xml.XmlDataDocument(ds)
            Dim transform As New System.Xml.Xsl.XslCompiledTransform()

            transform.Load("D:\Inetpub\wwwroot\WebSite2\SMI_Tracker_Download3.xsl")

            Dim writer As System.Xml.XmlTextWriter = New System.Xml.XmlTextWriter(fileName, System.Text.Encoding.UTF8)

            writer.Formatting = System.Xml.Formatting.Indented
            writer.Indentation = 4
            transform.Transform(doc, Nothing, writer)

        End Using
    End Sub

....BUT for some reason i'm having tons of error messages in my xsl template.

<?xml version="1.0" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="D:\Inetpub\wwwroot\WebSite2\SMI_Tracker_Download3.xsl" version="1.0" />
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no" />
 
  <xsl:template match="/">
    <XferFile>
      <xsl:call-template name="callCTfile" />
    </XferFile> 
  </xsl:template>
 
  <xsl:template name="callCTfile">
     <CTfile>
         <xsl:call-template name="callHeader" />
         <xsl:call-template name="callCTFpupilData" />
    </CTfile>
  </xsl:template>
 
 
  <xsl:template name="callHeader">
     <Header>
         <DocumentName>
             <xsl:value-of select="/NewDataSet/Table/DocumentName" />
         </DocumentName>
         <CTFversion>
             <xsl:value-of select="/NewDataSet/Table/CTFversion" />
         </CTFversion>
         <DateTime>
             <xsl:value-of select="/NewDataSet/Table/DateTime" />
         </DateTime>
         <DocumentQualifier>
             <xsl:value-of select="/NewDataSet/Table/DocumentQualifier" />
         </DocumentQualifier>
         <SupplierID>
             <xsl:value-of select="/NewDataSet/Table/SupplierID" />
         </SupplierID>
         <xsl:call-template name="callSourceSchool" />
         <xsl:call-template name="callDestSchool" />
     </Header>
 
  <xsl:template name="callSourceSchool">
         <SourceSchool>
             <LEA>
                 <xsl:value-of select="/NewDataSet/Table/SchoolSourceLEACode" />
             </LEA>
             <Estab>
                 <xsl:value-of select="/NewDataSet/Table/SourceSchoolEstablishmentCode" />
             </Estab>
             <SchoolName>
                 <xsl:value-of select="/NewDataSet/Table/SchoolName" />
             </SchoolName>
             <AcademicYear>
                 <xsl:value-of select="/NewDataSet/Table/AcademicYear" />
             </AcademicYear>
         </SourceSchool>
  </xsl:template>
 
  <xsl:template name="callDestSchool">
         <DestSchool>
             <LEA>
                 <xsl:value-of select="/NewDataSet/Table/DestLEA" />
             </LEA>
             <Estab>
                 <xsl:value-of select="/NewDataSet/Table/DestEstab" />
             </Estab>
         </DestSchool>
  </xsl:template>
 
  <xsl:template name="callCTFpupilData">
      <CTFpupilData>
          <xsl:call-template name="callPupil" />
      </CTFpupilData>
  </xsl:template>
 
 <xsl:template name="callPupil">
          <Pupil>
              <UPN>
                  <xsl:value-of select="/NewDataSet/Table/NationalUPN" />
              </UPN>
              <Surname>
              <xsl:value-of select="/NewDataSet/Table/LegalSurname" />
              </Surname>
              <ForeName>
              <xsl:value-of select="/NewDataSet/Table/FirstName" />
              </ForeName>
              <DOB>
              <xsl:value-of select="/NewDataSet/Table/DOB" />
              </DOB>
              <Gender>
              <xsl:value-of select="/NewDataSet/Table/Sex" />
              </Gender>
              <xsl:call-template name="callBasicDetails" />
              <xsl:call-template name="callAddress" />
              <xsl:call-template name="callContacts" />
              <xsl:call-template name="callSchoolHistory" />
              <xsl:call-template name="callSuppInfo" />
          </Pupil>
  </xsl:template>
 
 <xsl:template name="callBasicDetails">
              <BasicDetails>
                  <FormerUPN>
                      <xsl:value-of select="/NewDataSet/Table/PreviousNationalUPN" />
                  </FormerUPN>
                  <PreferredSurname>
                      <xsl:value-of select="/NewDataSet/Table/Surname" />
                  </PreferredSurname>
                  <PreferredForename>
                      <xsl:value-of select="/NewDataSet/Table/OtherNames" />
                  </PreferredForename>
                  <NCYearActual>
                      <xsl:value-of select="/NewDataSet/Table/NCYearActual" />
                  </NCYearActual>
                  <Ethnicity>
                      <xsl:value-of select="/NewDataSet/Table/Ethnicity" />
                  </Ethnicity>
                  <EthnicitySource>
                      <xsl:value-of select="/NewDataSet/Table/EthnicitySource" />
                  </EthnicitySource>
                  <xsl:call-template name="callLanguages" />
                  <FSMEligible>
                      <xsl:value-of select="/NewDataSet/Table/FSMEligible" />
                  </FSMEligible>
                  <MedicalFlag>
                      <xsl:value-of select="/NewDataSet/Table/MedicalFlag" />
                  </MedicalFlag>
                  <EnrolStatus>
                      <xsl:value-of select="/NewDataSet/Table/EnrolStatus" />
                  </EnrolStatus>
                  <Statemented>
                      <xsl:value-of select="/NewDataSet/Table/SENStatemented" />
                  </Statemented>
              </BasicDetails>
  </xsl:template>
 
  <xsl:template name="callLanguages">
                  <Languages>
                      <Type>
                          <LanguageQualifier>
                              <xsl:value-of select="/NewDataSet/Table/LanguageQualifier" />
                          </LanguageQualifier>
                          <Language>
                              <xsl:value-of select="/NewDataSet/Table/Language" />
                          </Language>
                      </Type>
                  </Languages>
  </xsl:template>
 
  <xsl:call-template name="callAddress" />
              <Address>
                  <AddressLines>
                      <Line1>
                          <xsl:value-of select="/NewDataSet/Table/AddressLine1" />
                      </Line1>
                      <Line2>
                          <xsl:value-of select="/NewDataSet/Table/AddressLine2" />
                      </Line2>
                      <Line3>
                          <xsl:value-of select="/NewDataSet/Table/AddressLine3" />
                      </Line3>
                      <Line4>
                          <xsl:value-of select="/NewDataSet/Table/Town" />
                      </Line4>
                      <Line5>
                          <xsl:value-of select="/NewDataSet/Table/County" />
                      </Line5>
                      <Postcode>
                          <xsl:value-of select="/NewDataSet/Table/PostCode" />
                      </Postcode>
                  </AddressLines>
              </Address>
  </xsl:template>

Open in new window

0
Comment
Question by:jsuanque
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 24017243
This line:

   <xsl:stylesheet xmlns:xsl="D:\Inetpub\wwwroot\WebSite2\SMI_Tracker_Download3.xsl" version="1.0" />

Should say:

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

The xsl namespace is standards defined so needs to be as above.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 24017251
Oops, back to front, that should say:

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

Author Comment

by:jsuanque
ID: 24024113
Hello Carl Tawn,

It was originally with that information but still recieved tons of error...I've attached the new xsl snippet...

Also just found that when i hover my cursor over line 3 (<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no" />) on the xsl:output method part it says "XML document cannot contain multiple root level elements".
<?xml version="1.0" standalone="yes"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" /> 
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="no" />
 
  <xsl:template match="/">
    <XferFile>
      <xsl:call-template name="callCTfile" />
    </XferFile> 
  </xsl:template>
 
  <xsl:template name="callCTfile">
     <CTfile>
         <xsl:call-template name="callHeader" />
         <xsl:call-template name="callCTFpupilData" />
    </CTfile>
  </xsl:template>
 
 
  <xsl:template name="callHeader">
     <Header>
         <DocumentName>
             <xsl:value-of select="/NewDataSet/Table/DocumentName" />
         </DocumentName>
         <CTFversion>
             <xsl:value-of select="/NewDataSet/Table/CTFversion" />
         </CTFversion>
         <DateTime>
             <xsl:value-of select="/NewDataSet/Table/DateTime" />
         </DateTime>
         <DocumentQualifier>
             <xsl:value-of select="/NewDataSet/Table/DocumentQualifier" />
         </DocumentQualifier>
         <SupplierID>
             <xsl:value-of select="/NewDataSet/Table/SupplierID" />
         </SupplierID>
         <xsl:call-template name="callSourceSchool" />
         <xsl:call-template name="callDestSchool" />
     </Header>
  </xsl:template>
 
  <xsl:template name="callSourceSchool">
         <SourceSchool>
             <LEA>
                 <xsl:value-of select="/NewDataSet/Table/SchoolSourceLEACode" />
             </LEA>
             <Estab>
                 <xsl:value-of select="/NewDataSet/Table/SourceSchoolEstablishmentCode" />
             </Estab>
             <SchoolName>
                 <xsl:value-of select="/NewDataSet/Table/SchoolName" />
             </SchoolName>
             <AcademicYear>
                 <xsl:value-of select="/NewDataSet/Table/AcademicYear" />
             </AcademicYear>
         </SourceSchool>
  </xsl:template>
 
  <xsl:template name="callDestSchool">
         <DestSchool>
             <LEA>
                 <xsl:value-of select="/NewDataSet/Table/DestLEA" />
             </LEA>
             <Estab>
                 <xsl:value-of select="/NewDataSet/Table/DestEstab" />
             </Estab>
         </DestSchool>
  </xsl:template>
 
  <xsl:template name="callCTFpupilData">
      <CTFpupilData>
          <xsl:call-template name="callPupil" />
      </CTFpupilData>
  </xsl:template>
 
 <xsl:template name="callPupil">
          <Pupil>
              <UPN>
                  <xsl:value-of select="/NewDataSet/Table/NationalUPN" />
              </UPN>
              <Surname>
              <xsl:value-of select="/NewDataSet/Table/LegalSurname" />
              </Surname>
              <ForeName>
              <xsl:value-of select="/NewDataSet/Table/FirstName" />
              </ForeName>
              <DOB>
              <xsl:value-of select="/NewDataSet/Table/DOB" />
              </DOB>
              <Gender>
              <xsl:value-of select="/NewDataSet/Table/Sex" />
              </Gender>
              <xsl:call-template name="callBasicDetails" />
              <xsl:call-template name="callAddress" />
              <xsl:call-template name="callContacts" />
              <xsl:call-template name="callSchoolHistory" />
              <xsl:call-template name="callSuppInfo" />
          </Pupil>
  </xsl:template>
 
 <xsl:template name="callBasicDetails">
              <BasicDetails>
                  <FormerUPN>
                      <xsl:value-of select="/NewDataSet/Table/PreviousNationalUPN" />
                  </FormerUPN>
                  <PreferredSurname>
                      <xsl:value-of select="/NewDataSet/Table/Surname" />
                  </PreferredSurname>
                  <PreferredForename>
                      <xsl:value-of select="/NewDataSet/Table/OtherNames" />
                  </PreferredForename>
                  <NCYearActual>
                      <xsl:value-of select="/NewDataSet/Table/NCYearActual" />
                  </NCYearActual>
                  <Ethnicity>
                      <xsl:value-of select="/NewDataSet/Table/Ethnicity" />
                  </Ethnicity>
                  <EthnicitySource>
                      <xsl:value-of select="/NewDataSet/Table/EthnicitySource" />
                  </EthnicitySource>
                  <xsl:call-template name="callLanguages" />
                  <FSMEligible>
                      <xsl:value-of select="/NewDataSet/Table/FSMEligible" />
                  </FSMEligible>
                  <MedicalFlag>
                      <xsl:value-of select="/NewDataSet/Table/MedicalFlag" />
                  </MedicalFlag>
                  <EnrolStatus>
                      <xsl:value-of select="/NewDataSet/Table/EnrolStatus" />
                  </EnrolStatus>
                  <Statemented>
                      <xsl:value-of select="/NewDataSet/Table/SENStatemented" />
                  </Statemented>
              </BasicDetails>
  </xsl:template>
 
  <xsl:template name="callLanguages">
                  <Languages>
                      <Type>
                          <LanguageQualifier>
                              <xsl:value-of select="/NewDataSet/Table/LanguageQualifier" />
                          </LanguageQualifier>
                          <Language>
                              <xsl:value-of select="/NewDataSet/Table/Language" />
                          </Language>
                      </Type>
                  </Languages>
  </xsl:template>
 
  <xsl:template name="callAddress">
              <Address>
                  <AddressLines>
                      <Line1>
                          <xsl:value-of select="/NewDataSet/Table/AddressLine1" />
                      </Line1>
                      <Line2>
                          <xsl:value-of select="/NewDataSet/Table/AddressLine2" />
                      </Line2>
                      <Line3>
                          <xsl:value-of select="/NewDataSet/Table/AddressLine3" />
                      </Line3>
                      <Line4>
                          <xsl:value-of select="/NewDataSet/Table/Town" />
                      </Line4>
                      <Line5>
                          <xsl:value-of select="/NewDataSet/Table/County" />
                      </Line5>
                      <Postcode>
                          <xsl:value-of select="/NewDataSet/Table/PostCode" />
                      </Postcode>
                  </AddressLines>
              </Address>
  </xsl:template>

Open in new window

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 24024139
I think all of your errors are probably being cause by one small typo. You shouldn't have the / at the end of the xsl:stylesheet line, as this is closing the tag and therefore it is treating the xsl:output tag as a root element.

The line should say:

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

Author Closing Comment

by:jsuanque
ID: 31564201
Thanks got it...aside from other syntaxes.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Activating .NET Framework 3.5 and which option to choose 5 55
asp.net, radiobuttonlist, c# 3 68
Adjust the codes 3 63
asp.net mvc5 6 33
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question