我正在使用 Jdeveloper 12c。我正在尝试使用 complexType 作为在另一个 complexType 中键入另一个元素的引用。 Jdev 告诉我它找不到 AddressInfo 引用。这是相关的代码片段,请帮助:
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="AddressInfo">
<sequence>
<element type="string" name="FirstName"/>
<element type="string" name="LastName"/>
<element type="string" name="Street"/>
<element type="string" name="City"/>
<element type="string" name="State"/>
<element type="short" name="ZipCode"/>
<element type="unsignedLong" name="PhoneNumber"/>
</sequence>
</complexType>
<complexType name="Billing">
<sequence>
<element name="PaymentCardName" type="string" maxOccurs="1"/>
<element name="PaymentCardNumber" type="unsignedLong"maxOccurs="1"/>
<element name="ExpirationDate" type="unsignedShort" maxOccurs="1"/>
<element name="BillingAddress" maxOccurs="1" type="AddressInfo"/>
</sequence>
</complexType>
最佳答案
为targetNamespace定义一个命名空间前缀:
xmlns:po="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
然后用它来引用AddressInfo:
<element name="BillingAddress" maxOccurs="1" type="po:AddressInfo"/>
你的错误就会消失。
总的来说(加上一些其他的小修复):
<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:po="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
targetNamespace="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="AddressInfo">
<sequence>
<element type="string" name="FirstName"/>
<element type="string" name="LastName"/>
<element type="string" name="Street"/>
<element type="string" name="City"/>
<element type="string" name="State"/>
<element type="short" name="ZipCode"/>
<element type="unsignedLong" name="PhoneNumber"/>
</sequence>
</complexType>
<complexType name="Billing">
<sequence>
<element name="PaymentCardName" type="string" maxOccurs="1"/>
<element name="PaymentCardNumber" type="unsignedLong" maxOccurs="1"/>
<element name="ExpirationDate" type="unsignedShort" maxOccurs="1"/>
<element name="BillingAddress" maxOccurs="1" type="po:AddressInfo"/>
</sequence>
</complexType>
</schema>
关于xml - XSD 重用 complexType 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33469455/
我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为
查看我的Ruby代码:h=Hash.new([])h[0]=:word1h[1]=h[1]输出是:Hash={0=>:word1,1=>[:word2,:word3],2=>[:word2,:word3]}我希望有Hash={0=>:word1,1=>[:word2],2=>[:word3]}为什么要附加第二个哈希元素(数组)?如何将新数组元素附加到第三个哈希元素? 最佳答案 如果您提供单个值作为Hash.new的参数(例如Hash.new([]),完全相同的对象将用作每个缺失键的默认值。这就是您所拥有的,那是你不想要的。您可以改用
本文主要介绍在使用Selenium进行自动化测试或者任务时,对于使用了iframe的页面,如何定位iframe中的元素文章目录场景描述解决方案具体代码场景描述当我们在使用Selenium进行自动化测试的时候,可能会遇到一些界面或者窗体是使用HTML的iframe标签进行承载的。对于iframe中的标签,如果直接查找是无法找到的,会抛出没有找到元素的异常。比如近在咫尺的例子就是,CSDN的登录窗体就是使用的iframe,大家可以尝试通过F12开发者模式查看到的tag_name,class_name,id或者xpath来定位中的页面元素,会抛出NoSuchElementException异常。解决
我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm
在Ruby中,是否有一种简单的方法可以将n维数组中的每个元素乘以一个数字?这样:[1,2,3,4,5].multiplied_by2==[2,4,6,8,10]和[[1,2,3],[1,2,3]].multiplied_by2==[[2,4,6],[2,4,6]]?(很明显,我编写了multiplied_by函数以区别于*,它似乎连接了数组的多个副本,不幸的是这不是我需要的)。谢谢! 最佳答案 它的长格式等价物是:[1,2,3,4,5].collect{|n|n*2}其实并没有那么复杂。你总是可以使你的multiply_by方法:c
给定两个大小相等的数组,如何找到不考虑位置的匹配元素的数量?例如:[0,0,5]和[0,5,5]将返回2的匹配项,因为有一个0和一个5共同;[1,0,0,3]和[0,0,1,4]将返回3的匹配项,因为0有两场,1有一场;[1,2,2,3]和[1,2,3,4]将返回3的匹配项。我尝试了很多想法,但它们都变得相当粗糙和令人费解。我猜想有一些不错的Ruby习惯用法,或者可能是一个正则表达式,可以很好地回答这个解决方案。 最佳答案 您可以使用count完成它:a.count{|e|index=b.index(e)andb.delete_at
我在尝试使用Nokogiri构建XML文档时遇到了一个小问题。我想将我的元素之一称为“文本”(请参阅下面粘贴代码的最底部)。通常,要创建一个新元素,我会执行类似以下的操作xml.text--但它似乎是.text是Nokogiri已经用来做其他事情的方法。因此,当我写这行时xml.textNokogiri没有创建名为的新元素但只是写了意味着成为元素内容的文本。我怎样才能让Nokogiri实际制作一个名为的元素??builder=Nokogiri::XML::Builder.newdo|xml|xml.TEI("xmlns"=>"http://www.tei-c.org/ns/1.0"
如果我想使用“create”构建策略创建和实例,然后想使用“attributes_for”构建策略进行验证,是否可以这样做?如果我在工厂中使用序列?在Machinistgem中有可能吗? 最佳答案 不太确定我是否完全理解。而且我不是机械师的用户。但听起来您只是想做这样的事情。@attributes=FactoryGirl.attributes_for(:my_object)my_object=MyObject.create(@attributes)my_object.some_property.should==@attributes
我想通过内部数组中的第一个元素从数组数组中找到唯一元素。例如a=[[1,2],[2,3],[1,5]我想要类似的东西[[1,2],[2,3]] 最佳答案 uniq方法需要一个block:uniq_a=a.uniq(&:first)或者如果您想就地进行:a.uniq!(&:first)例如:>>a=[[1,2],[2,3],[1,5]]=>[[1,2],[2,3],[1,5]]>>a.uniq(&:first)=>[[1,2],[2,3]]>>a=>[[1,2],[2,3],[1,5]]或者>>a=[[1,2],[2,3],[1,5]
我的任务是从数组中选择最高和最低的数字。我想我很清楚我想做什么,但只是努力以正确的格式访问信息以满足通过标准。defhigh_and_low(numbers)array=numbers.split("").map!{|x|x.to_i}array.sort!{|a,b|ba}putsarray[0,-1]end数字可能看起来像"80917234100",要通过,我需要输出"9234"。我正在尝试putsarray.first.last,但一直无法弄明白。 最佳答案 有Array#minmax完全满足您需要的方法:array=[80,