2009-09-14 103 views
2

我想验证以下XML,但我无法修复,请您发现错误?XML验证错误

<!-- menu: its a menu --> 
<menu id="Welcome"> 
    <!--audio: file to play --> 
    <audio src="D:\Telephony\VOXs\Welcome.vox" /> 
</menu> 

<!-- form: its a menu --> 
<menu id="LanguageSelection"> 
    <audio src="D:\Telephony\VOXs\LanguageSelection.vox" /> 

    <input timeout="5" max_timeout="2" max_invalid_input="2" valid_dtmfs="1, 2"> 

     <!-- noinput: if timeout occurred, execute this --> 
     <noinput> 
      <audio src="D:\Telephony\VOXs\Timeout.vox" /> 
     </noinput> 

     <!-- nomatch: if wrong dtmf given, following will execute --> 
     <nomatch> 
      <audio src="D:\Telephony\VOXs\InvalidInput.vox" /> 
     </nomatch> 

     <switch> 
      <dtmf-1> 
       <audio src="D:\Telephony\VOXs\EnglishSelected.vox" /> 
      </dtmf-1> 

      <dtmf-2> 
       <audio src="D:\Telephony\VOXs\UrduSelected.vox" /> 
      </dtmf-2> 
     </switch> 
    </input> 
</menu> 

<menu id="MainMenu"> 
    <audio src="D:\Telephony\VOXs\MainMenu.vox" /> 

    <input timeout="5" max_timeout="2" max_invalid_input="2" valid_dtmfs="1, 2"> 

     <!-- noinput: if timeout occurred, execute this --> 
     <noinput> 
      <audio src="D:\Telephony\VOXs\Timeout.vox" /> 
     </noinput> 

     <!-- nomatch: if wrong dtmf given, following will execute --> 
     <nomatch> 
      <audio src="D:\Telephony\VOXs\InvalidInput.vox"/> 
     </nomatch> 

     <switch> 
      <dtmf-1> 
       <goto menu="InformationMenu" /> 
      </dtmf-1> 

      <dtmf-2> 
       <goto menu="SupportMenu" /> 
      </dtmf-2> 
     </switch> 
    </input> 
</menu> 

我在验证Validome.org时出现以下错误。

错误:根元素后面的文档中的标记必须格式良好。

错误位置:< ENU ID = “语言选择”>

回答

2

您有多于一个顶级元素<menu>

请尝试以下操作。我添加了<MenuItems>作为顶级元素,并在最后关闭它。

<MenuItems> 
<!-- menu: its a menu --> 
<menu id="Welcome"> 
    <!--audio: file to play --> 
    <audio src="D:\Telephony\VOXs\Welcome.vox" /> 
</menu> 

<!-- form: its a menu --> 
<menu id="LanguageSelection"> 
    <audio src="D:\Telephony\VOXs\LanguageSelection.vox" /> 

    <input timeout="5" max_timeout="2" max_invalid_input="2" valid_dtmfs="1, 2"> 

     <!-- noinput: if timeout occurred, execute this --> 
     <noinput> 
       <audio src="D:\Telephony\VOXs\Timeout.vox" /> 
     </noinput> 

     <!-- nomatch: if wrong dtmf given, following will execute --> 
     <nomatch> 
       <audio src="D:\Telephony\VOXs\InvalidInput.vox" /> 
     </nomatch> 

     <switch> 
       <dtmf-1> 
         <audio src="D:\Telephony\VOXs\EnglishSelected.vox" /> 
       </dtmf-1> 

       <dtmf-2> 
         <audio src="D:\Telephony\VOXs\UrduSelected.vox" /> 
       </dtmf-2> 
     </switch> 
    </input> 
</menu> 

<menu id="MainMenu"> 
    <audio src="D:\Telephony\VOXs\MainMenu.vox" /> 

    <input timeout="5" max_timeout="2" max_invalid_input="2" valid_dtmfs="1, 2"> 

     <!-- noinput: if timeout occurred, execute this --> 
     <noinput> 
       <audio src="D:\Telephony\VOXs\Timeout.vox" /> 
     </noinput> 

     <!-- nomatch: if wrong dtmf given, following will execute --> 
     <nomatch> 
       <audio src="D:\Telephony\VOXs\InvalidInput.vox"/> 
     </nomatch> 

     <switch> 
       <dtmf-1> 
         <goto menu="InformationMenu" /> 
       </dtmf-1> 

       <dtmf-2> 
         <goto menu="SupportMenu" /> 
       </dtmf-2> 
     </switch> 
    </input> 
</menu> 
</MenuItems> 

您可以通过在ie中打开来快速检查ur xml。当我打开你的xml时,这就是我得到的。

Only one top level element is allowed in an XML document. Error processing resource 'file://Users/shoban/... 

<menu id="LanguageSelection"> 
-^ 
+0

你能解释一下发生了什么问题吗?为什么?以及如何解决? – akif 2009-09-14 11:57:37

+1

编辑答案。现在检查它是否清楚。 – Shoban 2009-09-14 11:59:20

+0

完美,谢谢! – akif 2009-09-14 12:02:53

2

您需要一个根级元素。例如,将菜单元素包装在<menus>标记中。

<menus> 
    <menu> 
    </menu> 
    <menu> 
    </menu> 
</menus> 
1

Well-formedness

SUMMARY:

The XML specification defines an XML document as a text which is well-formed, i.e., it satisfies a list of syntax rules provided in the specification. The list is fairly lengthy; some key points are:

  1. It contains only properly-encoded legal Unicode characters.
  2. None of the special syntax characters such as "<" and "&" appear except when performing their markup-delineation roles.
  3. The begin, end, and empty-element tags which delimit the elements are correctly nested, with none missing and none overlapping.
  4. The element tags are case-sensitive; the beginning and end tags must match exactly.
  5. There is a single "root" element which contains all the other elements.
1

您的问题的根本原因是,你的XML文档每个文件不止一个根元素。

在您的特定情况下的文档的基本结构是:

<menu></menu> 
<menu></menu> 
<menu></menu> 

即定义文档中3个元素。

为了定义需要围绕一个单一的根元素的三个要素如下的单个元素:

<menus> 
    <menu></menu> 
    <menu></menu> 
    <menu></menu> 
</menus> 

你可以找到更多在这个simple tutorial I found