XML validation error

I'm trying to validate the following XML, but I can't, could you spot the error?

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

      

I am getting the following error when validating with Validome.org .

Error: The markup in the document following the root element must be well formed.

Error position: < m enu id = "LanguageSelection">

+2


source to share


4 answers


You have more than one top level item <menu>

.

Try the following. I added <MenuItems>

as top level element and closed it at the end.

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

      



You can quickly check ur xml by opening it i.e. When I opened your xml this is what I got.

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

<menu id="LanguageSelection">
-^

      

+2


source


You need a root level element. For example, wrap your menu items inside a tag <menus>

.



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

      

+2


source


Well-formedness

SUMMARY:

The XML specification defines an XML document as text that is well-formed, i.e. it satisfies the list of syntax rules provided in the Specification. The list is quite long; some key points:

  • It contains only properly encoded legal Unicode characters.
  • None of the special syntaxes characters such as "<" and "&" appear when markup is markup.
  • Beginning, trailing, and empty element tags that delimit elements are properly nested, without and overlapping.
  • Item tags are case sensitive; start and end tags must match exactly.
  • There is one "root" element that contains all other elements.
+1


source


The root cause of your problem is that your XML document contains more than one root element for each file.

In your specific case, the main structure of your document is:

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

      

This defines three root elements in your document.

To define one element, you need to surround three elements with one root element like this:

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

      

You can read more about this simple tutorial I found .

+1


source







All Articles