2009-09-14 9 views
2

J'essaie de valider le code XML suivant, mais je suis incapable de le faire, pouvez-vous repérer l'erreur?Erreur de validation 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> 

je reçois l'erreur suivante lors de la validation avec Validome.org.

Erreur: Le balisage dans le document suivant l'élément racine doit être correctement formé.

erreur Position: < m enu id = "LanguageSelection">

Répondre

2

Vous avez plus d'un élément de niveau supérieur <menu>.

Essayez les solutions suivantes. J'ai ajouté <MenuItems> comme élément de premier niveau et l'ai fermé à la fin.

<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> 

Vous pouvez vérifier rapidement votre fichier xml en l'ouvrant dans ie. Quand j'ai ouvert votre xml, c'est ce que j'ai.

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

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

Pouvez-vous expliquer ce qui se passe mal et pourquoi? et comment résoudre? – akif

+1

Edite la réponse. Vérifiez maintenant si c'est clair. – Shoban

+0

Parfait, merci! – akif

2

Vous avez besoin d'un élément de niveau racine. Par exemple, enroulez les éléments de menu à l'intérieur d'une balise <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

La cause racine de votre problème est que votre document XML a plus d'un élément racine par fichier.

Dans votre cas particulier, la structure de base de votre document est:

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

qui est définit 3 éléments racine dans votre document.

Afin de définir un seul élément dont vous avez besoin pour entourer les trois éléments avec un seul élément racine comme suit:

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

Vous pouvez en savoir plus à ce simple tutorial I found.