XmlException "Root element is missing" on XslCompiledTransform.Load method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tomas

    #1

    XmlException "Root element is missing" on XslCompiledTransform.Load method

    When I try to load my xslt i get an xml exception with the message "Root
    element is missing". The stylesheet works when I preview it in stylus
    studio, but apparently not in my application. Any ideas what may be wrong?

    The stylesheet:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:transfor m version="1.0"
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" >
    <xsl:output indent="yes"/>
    <xsl:template match="/">
    <xsl:apply-templates select="PC"/>
    </xsl:template>

    <xsl:template match="PC">
    <xsl:element name="pcf:PC" namespace="http ://www.protang.se/ProFrame">
    <xsl:attribut e name="name">
    <xsl:value-of select="@name"/>
    </xsl:attribute>
    <xsl:apply-templates select="type"/>
    <xsl:apply-templates select="*/@name"/>
    </xsl:element>
    </xsl:template>

    <xsl:template match="type">
    <xsl:copy>
    <xsl:copy-of select="node()"/>
    </xsl:copy>
    </xsl:template>

    <xsl:template match="@name">
    <xsl:element name="{.}">
    <xsl:attribut e name="name">
    <xsl:value-of select="local-name(..)"/>
    </xsl:attribute>
    <xsl:if test="current() ='option'">
    <xsl:attribut e name="present">
    <xsl:value-of select="../@present"/>
    </xsl:attribute>
    </xsl:if>
    <xsl:copy-of select="../node()"/>
    </xsl:element>
    </xsl:template>

    </xsl:transform>


    <!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software
    Corporation. All rights reserved.
    <metaInformatio n>
    <scenarios ><scenario default="yes" name="Scenario1 " userelativepath s="yes"
    externalpreview ="no" url="file:///p:/Avdelningar/1107TC/ProFrame demo
    (TS)/demo form_data5.xml" htmlbaseurl="" outputurl=""
    processortype=" internal" useresolver="ye s" profilemode="0" profiledepth=""
    profilelength=" " urlprofilexml=" " commandline="" additionalpath= ""
    additionalclass path="" postprocessorty pe="none" postprocesscomm andline=""
    postprocessaddi tionalpath="" postprocessgene ratedext="" validateoutput= "no"
    validator="inte rnal"
    customvalidator =""/></scenarios><Mapp erMetaTag><Mapp erInfo
    srcSchemaPathIs Relative="yes" srcSchemaInterp retAsXML="no" destSchemaPath= ""
    destSchemaRoot= "" destSchemaPathI sRelative="yes"
    destSchemaInter pretAsXML="no" ><SourceSchem a
    srcSchemaPath=" file:///p:/Avdelningar/1107TC/ProFrame demo (TS)/demo
    form_data4.xml" srcSchemaRoot=" PC" AssociatedInsta nce=""
    loaderFunction= "document"
    loaderFunctionU sesURI="no"/></MapperInfo><Map perBlockPositio n><template
    match="/"></template></MapperBlockPosi tion><TemplateC ontext></TemplateContext ><MapperFilte r
    side="source"></MapperFilter></MapperMetaTag>
    </metaInformation >
    -->

  • Tomas

    #2
    Re: XmlException &quot;Root element is missing&quot; on XslCompiledTran sform.Load method

    Hrm, sorry, I was mistaken, the xmlexception doesn't come from the load
    method. Messed up my try/catch blocks...

    "Tomas" <tomas_sandkvis t@yahoo.comwrot e in message
    news:98BF39E5-A853-4C45-88CE-BA3A9ABF6C23@mi crosoft.com...
    When I try to load my xslt i get an xml exception with the message "Root
    element is missing". The stylesheet works when I preview it in stylus
    studio, but apparently not in my application. Any ideas what may be wrong?
    >
    The stylesheet:
    >
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:transfor m version="1.0"
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" >
    <xsl:output indent="yes"/>
    <xsl:template match="/">
    <xsl:apply-templates select="PC"/>
    </xsl:template>
    >
    <xsl:template match="PC">
    <xsl:element name="pcf:PC" namespace="http ://www.protang.se/ProFrame">
    <xsl:attribut e name="name">
    <xsl:value-of select="@name"/>
    </xsl:attribute>
    <xsl:apply-templates select="type"/>
    <xsl:apply-templates select="*/@name"/>
    </xsl:element>
    </xsl:template>
    >
    <xsl:template match="type">
    <xsl:copy>
    <xsl:copy-of select="node()"/>
    </xsl:copy>
    </xsl:template>
    >
    <xsl:template match="@name">
    <xsl:element name="{.}">
    <xsl:attribut e name="name">
    <xsl:value-of select="local-name(..)"/>
    </xsl:attribute>
    <xsl:if test="current() ='option'">
    <xsl:attribut e name="present">
    <xsl:value-of select="../@present"/>
    </xsl:attribute>
    </xsl:if>
    <xsl:copy-of select="../node()"/>
    </xsl:element>
    </xsl:template>
    >
    </xsl:transform>
    >
    >
    <!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software
    Corporation. All rights reserved.
    <metaInformatio n>
    <scenarios ><scenario default="yes" name="Scenario1 "
    userelativepath s="yes" externalpreview ="no"
    url="file:///p:/Avdelningar/1107TC/ProFrame demo (TS)/demo form_data5.xml"
    htmlbaseurl="" outputurl="" processortype=" internal" useresolver="ye s"
    profilemode="0" profiledepth="" profilelength=" " urlprofilexml=" "
    commandline="" additionalpath= "" additionalclass path=""
    postprocessorty pe="none" postprocesscomm andline=""
    postprocessaddi tionalpath="" postprocessgene ratedext=""
    validateoutput= "no" validator="inte rnal"
    customvalidator =""/></scenarios><Mapp erMetaTag><Mapp erInfo
    srcSchemaPathIs Relative="yes" srcSchemaInterp retAsXML="no"
    destSchemaPath= "" destSchemaRoot= "" destSchemaPathI sRelative="yes"
    destSchemaInter pretAsXML="no" ><SourceSchem a
    srcSchemaPath=" file:///p:/Avdelningar/1107TC/ProFrame demo (TS)/demo
    form_data4.xml" srcSchemaRoot=" PC" AssociatedInsta nce=""
    loaderFunction= "document"
    loaderFunctionU sesURI="no"/></MapperInfo><Map perBlockPositio n><template
    match="/"></template></MapperBlockPosi tion><TemplateC ontext></TemplateContext ><MapperFilte r
    side="source"></MapperFilter></MapperMetaTag>
    </metaInformation >
    -->

    Comment

    Working...