XSLT属性节点(ID)不能包含元素的孩子后创建(XSLT attribute node (id)

2019-06-27 20:56发布

通常我做在Weblogic12服务器的XSLT处理。 我一直运行到这个问题

net.sf.saxon.trans.DynamicError: An attribute node 
(id) cannot be created after the children of the containing element

在迁移之前,我们队都没有问题......

任何想法,为什么? 近日笔者从BEA Weblogic3升级到Oracle Weblogic的企业12还是我失去了一个图书馆吗?

这是困扰着我们整个团队! 谢谢!

编辑1:

错误指向<xsl:attribute name="id"><xsl:template name="makeErrorDiv">

<td>
            <xsl:copy-of select="@colspan | @align | @style | @valign | @class | @id | @name"/>
            <xsl:if test="@colspan = '1' and $columnWidth != '' and not(@suppressColWidth='true')"><xsl:attribute name="width"><xsl:value-of select="$columnWidth"/></xsl:attribute></xsl:if>
            <xsl:if test="@rowspan != '1'"><xsl:copy-of select="@rowspan"/></xsl:if>

            <xsl:if test="descendant::ErrMsg">
                <xsl:call-template name="makeErrorDiv"/>
            </xsl:if>
        </td>


<xsl:template name="makeErrorDiv">      
        <div style="display:none;">
            <xsl:choose>
                <xsl:when test="descendant::*[ParentId]">
                    <xsl:attribute name="id"><xsl:value-of select="descendant::ParentId[position() = 1]"/><![CDATA[$err]]></xsl:attribute>
                </xsl:when>         
                <xsl:when test="descendant::*[ErrMsg][Name]">
                    <xsl:attribute name="id"><xsl:value-of select="descendant::*[ErrMsg][position() = 1]/Name"/><![CDATA[$err]]></xsl:attribute>
                </xsl:when>
                <xsl:when test="not(descendant::*[ErrMsg])">
                    <xsl:variable name="name"><xsl:value-of select="descendant::*[Name][position() = 1]/Name"/></xsl:variable>
                    <xsl:variable name="parsed"><xsl:value-of select="substring-before($name, '!')"/></xsl:variable>
                    <xsl:attribute name="id"><!--error here! -->
                        <xsl:choose>
                            <xsl:when test="$parsed = ''"><xsl:value-of select="$name"/></xsl:when>
                            <xsl:otherwise><xsl:value-of select="$parsed"/></xsl:otherwise>
                        </xsl:choose>
                    <xsl:text><![CDATA[$err]]></xsl:text></xsl:attribute>   
                </xsl:when>
                <xsl:when test="descendant::*[ErrMsg][not(Name)]">
                    <xsl:variable name="name"><xsl:value-of select="descendant::*[Name][position() = 1]/Name"/></xsl:variable>
                    <xsl:variable name="parsed"><xsl:value-of select="substring-before($name, '!')"/></xsl:variable>
                    <xsl:attribute name="id">
                        <xsl:choose>
                            <xsl:when test="$parsed = ''"><xsl:value-of select="$name"/></xsl:when>
                            <xsl:otherwise><xsl:value-of select="$parsed"/></xsl:otherwise>
                        </xsl:choose>
                    <xsl:text><![CDATA[$err]]></xsl:text></xsl:attribute>                   
                </xsl:when>
            </xsl:choose>   
            <span style="color: #FF0000; font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; text-decoration: none;"><xsl:value-of select="descendant::ErrMsg[position() = 1]"/></span>
        </div>      
    </xsl:template>

XML样本...不知道,如果它是有帮助的......整个XML文件是1000+线

<DisclosureRowColor template="OneColumn" position="8" lastPosition="30" colCount="4" color1="#F2F8FE" color2="#ffffff">
                <Cell colspan="1">
                    <ListBox onchange="toggleAddressByAjax();">
                        <Name>APPLICATION_CUSTOMER.EMPLOYED_SINCE_MM!YLI</Name>
                        <Size>1</Size>
                        <Default rtexprvalue="true">mb.getValue("APPLICATION_CUSTOMER.EMPLOYED_SINCE_MM!YLI", "A")</Default>
                        <Map rtexprvalue="true">mb.getGenericLookup("V_YEAR")</Map>
                        <ReadOnly rtexprvalue="true">mb.isReadonly(2)</ReadOnly>
                    </ListBox>
                    <Label class="sTGBFBS">
                        <Caption> &amp;nbsp;&amp;nbsp;Jahre </Caption>
                    </Label>
                    <ListBox onchange="toggleAddressByAjax();">
                        <Name>APPLICATION_CUSTOMER.EMPLOYED_SINCE_MM!MLI</Name>
                        <Size>1</Size>
                        <Default rtexprvalue="true">mb.getValue("APPLICATION_CUSTOMER.EMPLOYED_SINCE_MM!MLI", "A")</Default>
                        <Map rtexprvalue="true">mb.getGenericLookup("V_MONTH")</Map>
                        <ReadOnly rtexprvalue="true">mb.isReadonly(2)</ReadOnly>
                    </ListBox>
                    <Label class="sTGBGBS">
                        <Caption> &amp;nbsp;&amp;nbsp;Monate </Caption>
                    </Label>
                    <ErrMsg/>
                </Cell>
            </DisclosureRowColor>

Answer 1:

认为你的问题可能是<xsl:text>的内部节点<xsl:attribute>元素

<xsl:text><![CDATA[$err]]></xsl:text></xsl:attribute>

我认为应该只说

<![CDATA[$err]]></xsl:attribute>

因为你创建一个属性,而不是文本节点。

更新:我试图重现错误,但不能。 但是,我确实发现撒克逊人使用的空白的属性。 你可能会想尝试摆脱一些一些XSL元素之间的空白。

<xsl:when test="not(descendant::*[ErrMsg])">
                <xsl:variable name="name"><xsl:value-of select="descendant::*[Name][position() = 1]/Name"/></xsl:variable>
                <xsl:variable name="parsed"><xsl:value-of select="substring-before($name, '!')"/></xsl:variable>
                <xsl:attribute name="id"><xsl:choose>
                        <xsl:when test="$parsed = ''"><xsl:value-of select="$name"/></xsl:when>
                        <xsl:otherwise><xsl:value-of select="$parsed"/></xsl:otherwise>
                    </xsl:choose><xsl:text><![CDATA[$err]]></xsl:text></xsl:attribute>   
            </xsl:when>

这可能会解决你的你看到实际的错误:

  <div style="display:none;"><xsl:choose>

我觉得一些文字一定是添加到您的“格”元素可以添加id属性之前。



文章来源: XSLT attribute node (id) cannot be created after the children of the containing element