XML / XSL:样式表不包含文档元素.样式表可能是空的,也可能不是XML构型文档



我已经在调试了几天,我似乎不知道为什么错误会告诉我The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

有什么问题?这是我一直在处理的代码:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/object">
    <div class="wp_codebox" id="divInput" style="width:850px;display:block;">
      <table width="100%">
        <tr>
          <td >
            <fieldset>
              <table align="center">
                <tbody>
                  <tr>
                    <td align="center">進捗</td>
                    <td colspan="7">
                      <xsl:for-each select="CT_A000000117">
                        <select style="width:50px;" id ="M221ATTR1" name="M221ATTR1">
                          <xsl:for-each select="option">
                            <option>
                              <xsl:attribute name="value">
                                <xsl:value-of select="value"/>
                              </xsl:attribute>
                              <xsl:if test="selected">
                                <xsl:attribute name="selected">
                                  <xsl:text>selected</xsl:text>
                                </xsl:attribute>
                              </xsl:if>
                              <xsl:value-of select="item"/>
                            </option>
                          </xsl:for-each>
                        </select>
                      </xsl:for-each>
                  </tr>
                  <tr>
                    <td align="center">担当課</td>
                    <td colspan="2">
                        <xsl:variable name="atr2" select="M221ATTR2"/>
                        <input type="text" id="M221ATTR2"  value="{$atr2}" size="35" maxlength="100"/>
                    </td>
                    <td align="center">計画名</td>
                    <td colspan="4">
                        <xsl:variable name="atr3" select="M221ATTR3"/>
                        <input type="text" id="M221ATTR3"  value="{$atr3}" size="60" maxlength="100"/>
                    </td>
                  </tr>
                  <tr>
                    <td align="center">申請地</td>
                    <td colspan="7">
                      <xsl:variable name="atr4" select="M221ATTR4"/>
                      <input type="text" id="M221ATTR4" value="{$atr4}" size="105" maxlength="100"/>
                    </td>
                  </tr>
                  <tr>
                    <td align="center">計画日</td>
                    <td colspan="2">
                      <input type="text" name="M221ATTR6" id="M221ATTR6" value="" size="11" onfocus="_calndarCtl.setInput('M221ATTR6','M221ATTR6', 'true');_calndarCtl.setDate();_calndarCtl.open(this,'DORODATE','M221ATTR6');" onkeydown="return _calndarCtl.keyHandler(event);">
                        <xsl:attribute name="value">
                          <xsl:if test="M221ATTR6 != ''">
                            <xsl:value-of select="M221ATTR6"/>
                          </xsl:if>
                        </xsl:attribute>
                      </input>&#160;<a href="javascript:_calndarCtl.setInput('M221ATTR6','M221ATTR6','true');_calndarCtl.setDate();_calndarCtl.open(document.getElementById('M221ATTR6'),'DORODATE','M221ATTR6');">
                        <img border="0" src="img/cal.gif" style="vertical-align:middle;"></img>
                      </a>
                      <td colspan="1" align="center">完了日</td>
                      <td colspan="4">    
                          <input type="text" name="M221ATTR5" id="M221ATTR5" value="" size="11" onfocus="_calndarCtl.setInput('M221ATTR5','M221ATTR5', 'true');_calndarCtl.setDate();_calndarCtl.open(this,'DORODATE','M221ATTR5');" onkeydown="return _calndarCtl.keyHandler(event);">
                            <xsl:attribute name="value">
                              <xsl:if test="M221ATTR5 != ''">
                                <xsl:value-of select="M221ATTR5"/>
                              </xsl:if>
                            </xsl:attribute>
                          </input>&#160;<a href="javascript:_calndarCtl.setInput('M221ATTR5','M221ATTR5','true');_calndarCtl.setDate();_calndarCtl.open(document.getElementById('M221ATTR5'),'DORODATE','M221ATTR5');">
                            <img border="0" src="img/cal.gif" style="vertical-align:middle;"></img>
                          </a>       
                      </td>
                  </tr>
                </tbody>
              </table>
            </fieldset>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <fieldset>
              <legend>地権者情報</legend>
              <div id="M221SyusenConsts"></div>
            </fieldset>
          </td>
        </tr>
        <tr>
          <td align="right">
            <table>
              <tr>
                <td>
                  <button type="button" class="button" eventid="cancel" id="InDataPrint" onclick="javascript:M221Doro.Print();">登録</button>
                </td>
                <td>
                  <button type="button" class="button" eventid="cancel" id="InDataAdd" onclick="javascript:M221Doro.Input();">削除</button>
                </td>
                <td>
                  <button type="button" class="button" eventid="cancel" id="InDataDel" onclick="javascript:M221Doro.Delete();">作図</button>
                </td>
                <td>
                  <button type="button" class="button" eventid="cancel" id="InFeatureAdd" onclick="javascript:M221Doro.CallEdit();">ファイリング</button>
                </td>
                <td>
                  <button type="button" class="button" eventid="cancel" onclick="javascript:M221Doro.InputClear();">キャンセル</button>
                </td>        
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <xsl:variable name="objectId" select="OBJECTID"/>
      <input type="hidden" id="hiddenObjectId" name="hiddenObjectId" value="{$objectId}" />
      <xsl:variable name="sLinkId" select="SLINKID"/>
      <input type="hidden" id="hiddenLinkId" name="hiddenLinkId" value="{$sLinkId}" />
      </div>
  </xsl:template>
</xsl:stylesheet>

尝试添加 <html>标签,但不起作用。

注意:有日本文本,我为此感到抱歉,但我正在一家日本公司工作:D

另外,我是新手。这是我第一次遇到这样的东西。我不知道XSL和XML。

XML声明应该像这样:<?xml version="1.0" encoding="utf-8"?>。然后样式表应从xsl:stylesheet元素开始,例如

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
...
</xsl:stylesheet>

在您的示例中,XML声明没有正确的语法(?问号丢失),其次是<head>元素。首先修复这些错误。

XSL文件,虽然应该是有效的XML。您有两个文档元素:[head]和[xsl:stylesheet]。您要尝试实现的目标可以通过将其内容的元素移动到相关[XSL:TEMPLATE]。

最新更新