[英]Parsing List<String> into XML using an XML Schema
尋找一種簡單的方法來分析字符串列表(或2d array [string1,string2]),其中字符串1是名稱,字符串2是內容。
結果應為.xml,僅包含在xml模式名稱與string1相同的所有位置填充的字符串2的數據。
<xs:include schemaLocation="common.xsd"/>
<xs:complexType name="part1Type">
<xs:all>
<xs:element name="noteCadre1" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre2" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre3" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre4" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre5" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre6" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre7" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre8" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre9" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre10" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre11" type="string5000Type" minOccurs="0"/>
<xs:element name="noteCadre12" type="string5000Type" minOccurs="0"/>
<xs:element name="infoResidence" type="home2Type" minOccurs="0"/>
<xs:complexType name="homeType">
<xs:sequence>
<xs:element name="lieu" type="string150Type"/>
<xs:element name="dateDebut" type="xs:date" minOccurs="0"/>
<xs:element name="dateFin" type="xs:date" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="home2Type">
<xs:sequence>
<xs:element name="item" type="homeType" maxOccurs="2"/>
</xs:sequence>
</xs:complexType>
List<String>
看起來像這樣:
清單1:{noteCadre1,noteCadre2,....,infoResidence.lieu.1,infoResidence.dateDebut.1,infoResidence.dateFin.1,infoResidence.lieu.2,infoResidence.dateDebut.2,...
清單2:{dataCadre1,dataCadre2,....,Street 100、01 / 01 / 20005、25 / 03/2005,....}
任何幫助,將不勝感激; 在網絡上瀏覽了兩天沒有成功。
您不能僅使用XML Schema來做到這一點:XML Schema是關於驗證XML文檔而不是解析。
為此,您需要添加第一步,將輸入文檔(字符串列表)轉換為目標XML表示形式。
使用任何編程語言(包括XSLT 2.0)似乎都非常容易實現,但這顯然超出了XML模式語言的范圍。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.