- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要你的帮助,因为我正在尝试解决这个问题但没有成功! :(
这是我的代码!
Territorialita.xsd
<?xml version="1.0" encoding="UTF-8"?>
<!-- xmlns:xs : assergno il namespace di default in cui troviamo gli elementi XML Schema -->
<!-- targetNamespace : definisco il namespace di destinazione, in cui salvare gli elementi definiti -->
<!-- xmlns:tns : assegno il namespace di destinazione -->
<!-- elementFormDefault : posto a "qualified" indica che tutti i documenti che usano gli elementi definiti in questa sintassi dovranno sempre dichiararne il namespace -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Territorialita"
xmlns:tns="http://www.example.org/Territorialita"
elementFormDefault="qualified">
<!-- definisco il tipo Territorialita -->
<xs:complexType name="TerritorialitaType">
<xs:sequence>
<xs:element name="Titolo" type="xs:string" />
<xs:element name="descrizioneSintetica" type="xs:string" />
<xs:element name="descrizioneDettagliata" type="xs:string" />
</xs:sequence>
<xs:attribute name="Codice" type="xs:integer" />
</xs:complexType>
<!-- definisco il tipo Array Territorialita -->
<xs:complexType name="ArrayTerritorialitaType">
<xs:sequence>
<xs:element name="Territorialita" type="tns:TerritorialitaType" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<!-- definisco la struttura del documento -->
<xs:complexType name="root">
<xs:sequence>
<xs:element name="ArrayTerritorialita" type="tns:ArrayTerritorialitaType" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Territorialita.xml
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<ArrayTerritorialita>
<Territorialita codice="1">
<Titolo>Elemento 1</Titolo>
<descrizioneSintetica> Descrizione sintetica - elemento 1</descrizioneSintetica>
<descrizioneDettagliata> Descrizione dettagliata - elemento 1</descrizioneDettagliata>
</Territorialita>
<Territorialita codice="2">
<Titolo>Elemento 2</Titolo>
<descrizioneSintetica> Descrizione sintetica - elemento 2</descrizioneSintetica>
<descrizioneDettagliata> Descrizione dettagliata - elemento 2</descrizioneDettagliata>
</Territorialita>
<Territorialita codice="3">
<Titolo>Elemento 3</Titolo>
<descrizioneSintetica> Descrizione sintetica - elemento 3</descrizioneSintetica>
<descrizioneDettagliata> Descrizione dettagliata - elemento 3</descrizioneDettagliata>
</Territorialita>
</ArrayTerritorialita>
</Root>
Root.java
package it.sogei.studi.territorialita.JAXB;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for root complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="root">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="ArrayTerritorialita" type="{http://www.example.org/Territorialita}ArrayTerritorialitaType" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlRootElement(name="root")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "root", propOrder = {
"arrayTerritorialita"
})
public class Root {
@XmlElement(name = "ArrayTerritorialita", required = true)
protected List<ArrayTerritorialitaType> arrayTerritorialita;
/**
* Gets the value of the arrayTerritorialita property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the arrayTerritorialita property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getArrayTerritorialita().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link ArrayTerritorialitaType }
*
*
*/
public List<ArrayTerritorialitaType> getArrayTerritorialita() {
if (arrayTerritorialita == null) {
arrayTerritorialita = new ArrayList<ArrayTerritorialitaType>();
}
return this.arrayTerritorialita;
}
}
ArrayTerritorialitaType.java
package it.sogei.studi.territorialita.JAXB;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ArrayTerritorialitaType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="ArrayTerritorialitaType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Territorialita" type="{http://www.example.org/Territorialita}TerritorialitaType" maxOccurs="unbounded"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayTerritorialitaType", propOrder = {
"territorialita"
})
public class ArrayTerritorialitaType {
@XmlElement(name = "Territorialita", required = true)
protected List<TerritorialitaType> territorialita;
/**
* Gets the value of the territorialita property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the territorialita property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getTerritorialita().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link TerritorialitaType }
*
*
*/
public List<TerritorialitaType> getTerritorialita() {
if (territorialita == null) {
territorialita = new ArrayList<TerritorialitaType>();
}
return this.territorialita;
}
}
TerritorialitaType.java
package it.sogei.studi.territorialita.JAXB;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for TerritorialitaType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="TerritorialitaType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="Titolo" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="descrizioneSintetica" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="descrizioneDettagliata" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* <attribute name="Codice" type="{http://www.w3.org/2001/XMLSchema}integer" />
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TerritorialitaType", propOrder = {
"titolo",
"descrizioneSintetica",
"descrizioneDettagliata"
})
public class TerritorialitaType {
@XmlElement(name = "Titolo", required = true)
protected String titolo;
@XmlElement(required = true)
protected String descrizioneSintetica;
@XmlElement(required = true)
protected String descrizioneDettagliata;
@XmlAttribute(name = "Codice")
protected int codice;
/**
* Gets the value of the titolo property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTitolo() {
return titolo;
}
/**
* Sets the value of the titolo property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTitolo(String value) {
this.titolo = value;
}
/**
* Gets the value of the descrizioneSintetica property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDescrizioneSintetica() {
return descrizioneSintetica;
}
/**
* Sets the value of the descrizioneSintetica property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDescrizioneSintetica(String value) {
this.descrizioneSintetica = value;
}
/**
* Gets the value of the descrizioneDettagliata property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getDescrizioneDettagliata() {
return descrizioneDettagliata;
}
/**
* Sets the value of the descrizioneDettagliata property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setDescrizioneDettagliata(String value) {
this.descrizioneDettagliata = value;
}
/**
* Gets the value of the codice property.
*
* @return
* possible object is
* {@link BigInteger }
*
*/
public int getCodice() {
return codice;
}
/**
* Sets the value of the codice property.
*
* @param value
* allowed object is
* {@link BigInteger }
*
*/
public void setCodice(int value) {
this.codice = value;
}
}
Test.java
package it.sogei.studi.territorialita.main;
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import it.sogei.studi.territorialita.JAXB.ArrayTerritorialitaType;
import it.sogei.studi.territorialita.JAXB.Root;
public class Test {
public static void main(String[] args) {
// definisco il percorso del file XML
String filePath = "src/it/sogei/studi/territorialita/risorse/Territorialita.xml";
try
{
File file = new File(filePath);
JAXBContext jaxbContext = JAXBContext.newInstance(it.sogei.studi.territorialita.JAXB.Root.class);
Unmarshaller unmarhsaller = jaxbContext.createUnmarshaller();
ArrayTerritorialitaType ArrayTerr = (ArrayTerritorialitaType) unmarhsaller.unmarshal(file);
System.out.print(ArrayTerr);
System.out.println("**** PROGRAMMA TERMINATO ****");
}
catch(JAXBException e)
{
e.printStackTrace();
}
}
}
XML 文档必须有一个根元素,然后是一个子节点数组 (arrayTerritorialita
)。但是当我尝试解码时,出现此错误:
javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"Root"). Expected elements are <{http://www.example.org/Territorialita}root>
最佳答案
您的 XML 文件不符合 XML 架构定义的要求。使用它作为根元素:
<root xmlns="http://www.example.org/Territorialita">
...
</root>
提示:获取有效 XML 文档的一个好方法是创建一小组表示文档的 Java 对象并将其编码。
关于java - 解码错误 : unexpected element (uri: local:), 预期元素为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36204193/
下面两个CSS选择器有什么区别? 来自解释here ,它们听起来一样吗? div p{} 选择div元素内的所有p元素 div > p{} 选择父级为 div 元素的所有 p 元素。 最佳答案 区别在
我需要怎么做: 目前,事实证明: 我更喜欢它看起来像: 最佳答案 有了这些空行,看起来您的 select 语句是(正确地)选择您
用替换元素是否有效至 .在这种情况下,我想要, 这样我就可以在...中附加验证数据。这也可以从 中实现吗?或 等等? 最佳答案 标签没有 而且不需要一个。同样适用于 和 .您可以将验证数据作为
我刚刚发现了 Angular 1.2.1 的一个奇怪问题,在 this fiddle 中进行了演示。 (在 IE、FF 和 Chrome 中测试):如果我创建一个非常简单的模板化指令,它无法像 那样
我正在尝试使用 Jsoup 迭代 java 中的两个元素,但是,我收到运行时异常错误。看来我无法将nodes.Element 的类型转换为element.Element。 非常感谢您的帮助,谢谢。 代
假设我的文档中有一组元素,它们是单个对象的子元素。这些元素中的每一个都使用不同的参数注册一个新的事件监听器。如果我丢弃父对象,是否需要手动取消注册所有 eventListener?或者浏览器是否跟踪所
我不应该在我的应用程序中使用 jQuery,但我有一个场景,我需要元素的偏移量,而不是使用 $(element).offset() 我已经使用了 angular.element(element).of
我是TS的新手,我想知道为什么我在以下代码中遇到类型错误(简化):。错误在`{iconMap[名称]}中:。“元素隐式具有‘any’类型,因为‘字符串’类型的表达式不能用于索引类型‘{Categori
我是TS的新手,我想知道为什么我在以下代码中遇到类型错误(简化):。错误在`{iconMap[名称]}中:。“元素隐式具有”any“类型,因为”string“类型的表达式不能用于索引类型”{ Cate
什么意思: Separator.Iterator.Element == Self.Iterator.Element.Iterator.Element 在this (Swift 标准库)swift 实例
是否可以在 img 元素上使用前后伪选择器?认为它是但没有任何运气,将 css 切换到 div 并且它工作正常。 .page-overhang 类是 img 元素。 // page overhang
我在 UI 中的按钮 Click 事件上有以下代码,它返回一个 MS-Excel 文件。它在第一次点击事件中完美运行,但之后返回以下错误。 任何建议,我怎样才能摆脱它? ERROR: Uncaught
如何在 CSS 中编写这个想法: 选择 ElementA 内但不在 ElementB 内且 ElementB 在 ElementA 内的每个元素。 这是一个例子:
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
如果我在 C# 中的 XElement myXML 变量中有以下 XML, myvalue 要获得“myvalue”,我需要执行以下操作: myXML.Element(
我找不到用户名和密码字段。我检查元素,并尝试通过 id、xpath 或 css 选择器查找它,但它给出错误 NoSuchElementException: Message: no such eleme
我的任务是在用户点击它时从输入框中删除占位符并使标签可见。如果用户未在其中再次填写任何内容,请放回占位符并使标签不可见。 我可以隐藏它但不能重新分配它。我试过 element.setAttribute
我正在编写一个 c# 类来编写一个 XML 文件,该文件需要与我们使用的现有 XML 的结构完全匹配,这样一些遗留系统就不会混淆。 当一个元素的InnerText值为null时,我需要xml元素的元素
自定义元素的一个常见做法,至少在 Polymer(最流行的 Web 组件框架)中,是定义一个新的自定义元素。恕我直言,这对 来说不是一个好习惯呈现 元素,因为该元素无法逐步呈现,必须等到它被加载(注册
我正在尝试跟踪元素的可见性及其显示的控制台错误:“元素“a[data-vars-ei]”必须是 AMP 元素”。 但是在点击跟踪的情况下,类似的事情工作正常。 我无法理解为什么会发生这种情况以及我应该
我是一名优秀的程序员,十分优秀!