草庐IT

XML 验证错误

coder 2024-07-04 原文

我正在尝试验证以下 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 验证时收到以下错误.

错误:文档中跟在根元素之后的标记必须格式正确。

错误位置:menu id="LanguageSelection">

最佳答案

你有不止一个顶级元素<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 中打开它来快速检查您的 xml。当我打开你的 xml 时,这就是我得到的。

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

<menu id="LanguageSelection">
-^

关于XML 验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1421078/

有关XML 验证错误的更多相关文章

  1. ruby-on-rails - 如何验证 update_all 是否实际在 Rails 中更新 - 2

    给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru

  2. ruby - 具有身份验证的私有(private) Ruby Gem 服务器 - 2

    我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..

  3. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  4. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  5. ruby-on-rails - 如果为空或不验证数值,则使属性默认为 0 - 2

    我希望我的UserPrice模型的属性在它们为空或不验证数值时默认为0。这些属性是tax_rate、shipping_cost和price。classCreateUserPrices8,:scale=>2t.decimal:tax_rate,:precision=>8,:scale=>2t.decimal:shipping_cost,:precision=>8,:scale=>2endendend起初,我将所有3列的:default=>0放在表格中,但我不想要这样,因为它已经填充了字段,我想使用占位符。这是我的UserPrice模型:classUserPrice回答before_val

  6. ruby-on-rails - 如何验证非模型(甚至非对象)字段 - 2

    我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss

  7. ruby-on-rails - 如何将验证与模型分开 - 2

    我有一些非常大的模型,我必须将它们迁移到最新版本的Rails。这些模型有相当多的验证(User有大约50个验证)。是否可以将所有这些验证移动到另一个文件中?说app/models/validations/user_validations.rb。如果可以,有人可以提供示例吗? 最佳答案 您可以为此使用关注点:#app/models/validations/user_validations.rbrequire'active_support/concern'moduleUserValidationsextendActiveSupport:

  8. ruby-on-rails - 跳过状态机方法的所有验证 - 2

    当我的预订模型通过rake任务在状态机上转换时,我试图找出如何跳过对ActiveRecord对象的特定实例的验证。我想在reservation.close时跳过所有验证!叫做。希望调用reservation.close!(:validate=>false)之类的东西。仅供引用,我们正在使用https://github.com/pluginaweek/state_machine用于状态机。这是我的预订模型的示例。classReservation["requested","negotiating","approved"])}state_machine:initial=>'requested

  9. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  10. ruby - 如何在 Rails 4 中使用表单对象之前的验证回调? - 2

    我有一个服务模型/表及其注册表。在表单中,我几乎拥有服务的所有字段,但我想在验证服务对象之前自动设置其中一些值。示例:--服务Controller#创建Action:defcreate@service=Service.new@service_form=ServiceFormObject.new(@service)@service_form.validate(params[:service_form_object])and@service_form.saverespond_with(@service_form,location:admin_services_path)end在验证@ser

随机推荐