私は初めて自分のXMLを検証するためにXMLスキーマを作ろうとしています。XMLスキーマに属性を含めることはできません。 (http://www.w3.org/2001/XMLSchema-instance used)
<?xml version="1.0" encoding="utf-8"?>
<CrystalReport
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:crystal-reports:schemas:report-detail
http://www.businessobjects.com/products/xml/CR2008Schema.xsd"
xmlns="urn:crystal-reports:schemas:report-detail"
>
<ReportHeader>
<Section SectionNumber="0">
<Text Name="Text9">
...
私のXMLスキーマ(お知らせライン2、3及び20)::私のXML(お知らせ "-instance
" と "SectionNumber="0"
")の
スタート
<?xml version="1.0" encoding="utf-8"?>
<xsi:schema id="XMLSchema_varslings1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:crystal-reports:schemas:report-detail"
elementFormDefault="qualified"
targetNamespace="urn:crystal-reports:schemas:report-detail">
<xsi:element name="CrystalReport" type="CrystalReportType"/>
<xsi:complexType name="CrystalReportType">
<xsi:sequence maxOccurs="unbounded">
<xsi:element name="ReportHeader" type="ReportHeaderType"/>
</xsi:sequence>
</xsi:complexType>
<xsi:complexType name="ReportHeaderType">
<xsi:sequence>
<xsi:element name="Section" type="SectionType"/>
<!-- This is line 19....................................... -->
<xsi:attribute name="SectionNumber" type="xsi:Integer"/>
</xsi:sequence>
</xsi:complexType>
<xsi:complexType name="SectionType">
<xsi:sequence maxOccurs="unbounded">
<xsi:element name="Text" type="TextType" />
</xsi:sequence>
</xsi:complexType>
<xsi:complexType name="TextType">
<xsi:sequence maxOccurs="unbounded">
<xsi:element name="TextValue" type="xsi:string" />
</xsi:sequence>
</xsi:complexType>
</xsi:schema>
は、私はこのエラーを取得します私は解決できません: "The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'.
"
"-instance
"をスキーマから削除すると、私はboveエラーが発生しましたが、属性「<xsi:attribute name="SectionNumber" type="xsi:Integer"/>
」のコードを使用できません。
私の実際の問題が-instance
部分であるかどうかわからない、またはスキーマに属性を書き込む/含める別の方法があります。これをどうすれば解決できますか?
ありがとう、本当に良い答えです。それはセンスが大事です。接頭辞を 'ns'ではなく' xs'に変更したのでしょうか?すぐにテストを開始します。 – radbyx
そうです、私は固定された 'xs'を意味しました。 – svick
また、今私はhahaをしたように 'xs'を使っていて、' xsi'を使わなかったのは理にかなっています:) – radbyx