任何人都可以帮助我理解为什么这段代码会抛出xml提前结束的文件错误?coldfusion xml xslt文件错误提前结束
<cfxml variable="xslt">
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--- Start by matching the root node. --->
<xsl:template match="/nodes">
<nodes>
<!---
Inside our new root node, output all the top-
level NODE elements (ie. those with a parentID
value of zero).
--->
<xsl:call-template name="getChildNodes" />
</nodes>
</xsl:template>
<!--- This function outputs all child node elemenst of the node with the given ID. --->
<xsl:template name="getChildNodes">
<!--- Param our parent ID. --->
<xsl:param name="parentID" select="0" />
<!--- Select all the child node elements that have the given parentID. --->
<xsl:for-each select="//node[@parent-id=$parentID]">
<!--- Sort this node list on ID. --->
<xsl:sort select="@id" />
<!--- Output the new node. --->
<node id="{@id}" parent-id="{@parent-id}" name="{@name}">
<!---
Now that are outputting a given node, let's
output all the child nodes that might be a
descendant of it.
NOTE: This is the recursive aspect of this
XSTL approach.
--->
<xsl:call-template name="getChildNodes">
<xsl:with-param name="parentID" select="@id"/>
</xsl:call-template>
</node>
</xsl:for-each>
</xsl:template>
</xsl:transform>
</cfxml>
上面的段是这个全功能的一部分:
<cffunction name="xmlNav" access="private" returntype="struct" output="false">
<cfargument name="qGetNav" type="query" required="true">
<cfset var qNav = arguments.qGetNav>
<cfset var rawNodeTree="">
<cfset var xslt="">
<cfxml variable="rawNodeTree">
<cfoutput>
<nodes>
<cfloop query="qNav">
<node id="#qNav.navid#" parent-id="#qNav.navparentID#" name="#qNav.TextDesc#"/>
</cfloop>
</nodes>
</cfoutput>
</cfxml>
<cfxml variable="xslt">
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--- Start by matching the root node. --->
<xsl:template match="/nodes">
<nodes>
<!---
Inside our new root node, output all the top-
level NODE elements (ie. those with a parentID
value of zero).
--->
<xsl:call-template name="getChildNodes" />
</nodes>
</xsl:template>
<!--- This function outputs all child node elemenst of the node with the given ID. --->
<xsl:template name="getChildNodes">
<!--- Param our parent ID. --->
<xsl:param name="parentID" select="0" />
<!--- Select all the child node elements that have the given parentID. --->
<xsl:for-each select="//node[@parent-id=$parentID]">
<!--- Sort this node list on ID. --->
<xsl:sort select="@id" />
<!--- Output the new node. --->
<node id="{@id}" parent-id="{@parent-id}" name="{@name}">
<!---
Now that are outputting a given node, let's
output all the child nodes that might be a
descendant of it.
NOTE: This is the recursive aspect of this
XSTL approach.
--->
<xsl:call-template name="getChildNodes">
<xsl:with-param name="parentID" select="@id"/>
</xsl:call-template>
</node>
</xsl:for-each>
</xsl:template>
</xsl:transform>
</cfxml>
<cfset myXmlNav.xmlNav=rawNodeTree>
<cfset myXmlNav.IsXml=IsXML(myXmlNav.xmlNav)>
<cfreturn myXmlNav>
</cffunction>
我已确认我可以在它自己的CFC
这很容易调试。从“”的内容中删除行,并查看它停止工作的位置。 XSLT本身看起来很好。 –
Tomalak
2012-03-25 21:27:47
在我的回复中取得了一个高峰,我尝试删除所有内容,仍然没有去 – 2012-03-25 21:29:53
您的CF页面中有一个空的'',这会产生错误?难以置信。 –
Tomalak
2012-03-25 21:31:18