大家好我有我的XML文件如下
的名字 XML XMLFile2.xml
<?xml version="1.0"?>
<Product ProductID="123"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Product.xsd">
<ProductName>XYZ</ProductName>
</Product>
Run Code Online (Sandbox Code Playgroud)
我的XSD情况如下
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Product"
targetNamespace="http://tempuri.org/Product.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/Product.xsd"
xmlns:mstns="http://tempuri.org/Product.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Product">
<xs:complexType>
<xs:sequence>
<xs:element name="ProductName" type="xs:string"></xs:element>
</xs:sequence>
<xs:attribute name="ProductID" type="xs:int" use="required"/>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
这是我的代码
string strPath = Server.MapPath("XMLFile2.xml");
XmlTextReader r = new XmlTextReader(strPath);
XmlValidatingReader v = new XmlValidatingReader(r);
v.ValidationType = ValidationType.Schema;
v.ValidationEventHandler +=
new ValidationEventHandler(MyValidationEventHandler);
while (v.Read())
{
}
v.Close();
if (isValid)
Response.Write("Document is valid");
else
Response.Write("Document is invalid");
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Validation event …Run Code Online (Sandbox Code Playgroud) 我想知道如何从XSD文件中创建java中的Object树.这有什么框架吗?
函数签名有点接近这个:
TreeSet<Object> convertToTree(File xsdFile);
Run Code Online (Sandbox Code Playgroud)
所以你可以看到函数convertToTree应该读取xsd文件并生成一个Tree集合.
也有人可以发一些例子吗?
我刚从Eclipse Indigo(3.7)升级到Eclipse Juno(4.2),我的WSDL在Indigo中没有任何问题进行验证,我现在得到一个奇怪的警告和错误,我不明白.
WSDL片段:
<wsdl:types>
<xsd:schema
targetNamespace="http://www.domain.com/ClientServices/LendingSimulation/V1"
xmlns:cpReq="http://www.domain.com/ClientServices/LendingSimulation/CalculateProfitabilityRequest"
xmlns:cpRes="http://www.domain.com/ClientServices/LendingSimulation/CalculateProfitabilityResponse"
xmlns:error="http://www.domain.com/fw/errorMgmt">
<xsd:import namespace="http://www.domain.com/ClientServices/LendingSimulation/CalculateProfitabilityRequest" schemaLocation="CalculateProfitabilityRequest.xsd" />
<xsd:element name="calculateProfitabilityRequest" type="cpReq:CalculateProfitabilityRequestType" />
</xsd:schema>
</wsdl:types>
Run Code Online (Sandbox Code Playgroud)
Juno使用以下警告标记xsd:import行:
XSD: The location 'CalculateProfitabilityRequest.xsd' has not been resolved
Run Code Online (Sandbox Code Playgroud)
然后标记xsd:element行,并显示以下错误:
XSD: Type reference 'http://www.domain.com/ClientServices/LendingSimulation/CalculateProfitabilityRequest#CalculateProfitabilityRequestType' is unresolved
Run Code Online (Sandbox Code Playgroud)
我很难过.我不仅不理解警告或错误消息的含义,我不明白为什么Juno将此标记为问题,但在Indigo中没有问题.如果我按Ctrl键单击schemaLocation,Eclipse将打开相关的xsd文件,因此Eclipse不会找到该文件.
我试过清理这个项目,但它没有任何区别.
编辑
我咬紧牙关,决定重新安装Indigo Java EE(3.7).但是,现在当我加载我的项目时,我得到了与Juno相同的错误!所以它似乎不是Juno本身,而是我配置中的某些东西是不正确的.但是,我不知道在哪里可以找到问题,或者为什么Eclipse抱怨该位置没有得到解决.这几乎就像我必须以某种方式预装Eclipse中的文件,但我不知道如何.
如果我删除项目,并将项目重新加载为现有Maven项目,则所有警告和错误消息都将消失.但是,该项目随后与我的SCM无关.如果我通过SCM加载它,那么我会重新发生此错误.我猜测项目配置必须有一些东西,但是方面是相同的,所以我不知道哪个配置是不同的.无论如何要告诉?
任何想法或建议赞赏!
我有两个XML文件file1.xml和file2.xml.我也有每个文件的模式,file1.xsd并file2.xsd尊重.
我xjc用来创建基于file1.xsd(称为model(1))的java类,并基于file2.xsd(称为model(2))创建类.
我使用model(1)来解析文件JAXB库中的file1.xml .我想将此数据从模型(1)转换为模型(2),然后将转换后的数据封送到file2.xml
是否可以将数据从模型(1)转换为模型(2)?我可以合并ObjectFactories吗?我该怎么做?
我正在尝试 使用此验证工具验证此站点地图:http://animal.org.il/post.xml:http://www.xmlcheck.com/checkurl.php
我得到这个错误上的所有图片:图片每日新闻:错误1845:元素"{http://www.google.com/schemas/sitemap-image/1.1}image":没有匹配的全局元素声明可用,但要求通过严格的通配符.
以下是我的站点地图的当前来源的片段,其中显示了一些图片:图片代码:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://animal.org.il/wp-content/plugins/bwp-google-xml-sitemaps/xsl/bwp-sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://animal.org.il/to-be-goose/</loc>
<lastmod>2012-07-24T09:57:18+00:00</lastmod>
<changefreq>monthly</changefreq>
<priority>0.4</priority>
<image:image>
<image:loc>http://animal.org.il/wp-content/gallery/goose/goose-nature.jpg</image:loc>
<image:title>???? ????</image:title>
<image:caption>???? ???? ?? ?? ??? ???? ????????? ??? ???, ?? ??????? ???? ??????? ??? ?? ???? ????? ??? ?????.</image:caption>
</image:image>
<image:image>
<image:loc>http://animal.org.il/wp-content/gallery/goose/goose-feathers.jpg</image:loc>
<image:title>?????? ??????</image:title>
<image:caption>???? ???? ?????? ?? ???? ????? ???? ????? ???????. ???? ????? ?? ?????? ?<a href="http://anonymous.org.il/cat40.html" target="_blank">?????</a> ?? ????????? ??????? (Kalla Fatka, TV4)</image:caption>
</image:image>
<image:image>
<image:loc>http://animal.org.il/wp-content/gallery/goose/goose-foie-gras.jpg</image:loc>
<image:title>?? ??????? ??? …Run Code Online (Sandbox Code Playgroud) 配置Hibernate时,我的配置文件中出现以下错误.
Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.1.xsd)
Run Code Online (Sandbox Code Playgroud)
当我查看"更多详情"时,它给了我以下内容:
sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/beans,identifiedType'.
Run Code Online (Sandbox Code Playgroud)
我有一个applicationContext.xml文件,其架构定义(我导入我的hibernate-context.xml文件)如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
..
..
<!-- Imports datasource configuration -->
<import resource="hibernate-context.xml" />
Run Code Online (Sandbox Code Playgroud)
我的hibernate-context.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/mvc …Run Code Online (Sandbox Code Playgroud) 有谁知道我在哪里可以找到BizTalk ESB Toolkit的错误消息的XSD副本?我有一个示例XML文件,我可以用它来生成这样的模式,但如果有任何未填充的可填充元素或类型限制,那么这些元素将无法从生成的模式中获得.我试图追踪XSD的副本,但到目前为止还没有任何运气.
示例文件中的名称空间和根元素包含在下面:
<ns0:FaultMessage xmlns:ns0="http://schemas.microsoft.biztalk.practices.esb.com/exceptionhandling">
<!-- ... -->
</ns0:FaultMessage>
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的任何帮助.
过去几天,我一直在提高我的XML模式技能,并且整整一整天,我忙于尝试了解与模式有关的名称空间的复杂性。最令我震惊的form="qualified|unqualified"是非全局性<element>和<attribute>元素上的属性似乎毫无用处。
我的问题是:该form属性实际上是在XML模式/ XML文档中增加了表达能力,还是只是使某些XML文档的表示法更容易/不同?
我了解到,当所有元素都使用命名空间进行限定时(通常只需要文档元素上的一个xmlns =“ xyz”属性),需要遵循某种模式的XML文档通常更容易编写。 ?为什么有人会为所有不合格的非全局元素烦恼呢?
目标:创建一个complexType,允许元素"skip"以任意顺序包含任意元素,并且无误地验证我的xml.
架构:skip.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns="http://www.example.com/main"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/main"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
>
<xs:complexType name="skip">
<xs:sequence>
<xs:any minOccurs="1"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
我将skip.xsd导入到我的main.xsd中
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:esc="http://www.escmatrix.com/main"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/main"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
>
<xs:include
schemaLocation="http://www.example/skip" />
<xs:element name="tasks">
<xs:complexType>
<xs:choice minOccurs="0"
maxOccurs="unbounded" >
<xs:element name="skip"
type="esc:skip" />
</xs:choice>
</xs:complexType>
</xs:element>
<xs:schema>
Run Code Online (Sandbox Code Playgroud)
我需要验证可以具有以下形式的xml:
<skip>
<anyelement1></anyelement1>
<anyelement2></anyelement2>
<anyelementN></anyelementN>
</skip>
Run Code Online (Sandbox Code Playgroud)
问题:验证时出错; "cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素'anyelement1'的声明"
我按照这个线程的说明,从这个XML:
<?xml version="1.0" encoding="UTF-8" ?>
<my_report>
<something>
<foo>
Yes
</foo>
</something>
<something_else>
<id>4</id>
<foo>Finally</foo>
<score>0.2</score>
</something_else>
</my_report>
Run Code Online (Sandbox Code Playgroud)
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="my_report">
<xs:complexType>
<xs:sequence>
<xs:element name="something">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="foo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="something_else">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:byte" name="id"/>
<xs:element type="xs:string" name="foo"/>
<xs:element type="xs:float" name="score"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
然后我pyxben -u my_schema.csd -m my_schema在shell中调用,然后尝试使用绑定构建对象:
from my_schema import my_report
my_xml_report = my_report()
Run Code Online (Sandbox Code Playgroud)
这似乎工作到目前为止(我可以访问my_xml_report.something).但是,当我尝试填充嵌套元素时:
my_xml_report.something.foo …Run Code Online (Sandbox Code Playgroud)