1
我是XSLT的新手我試圖將名稱值對轉換爲其對應的XML。此功能主要用於對標準進行特殊擴展的情況。我想要轉換的文件如下。xslt將xml轉換爲相應的名稱值對
<ODEventNotificationExtraField>
<callCode>1</callCode>
<callbackType>All </callbackType>
<callbackEmail>[email protected] </callbackEmail>
</ODEventNotificationExtraField>
以下內容:基於字段名稱例如CallCode我會知道它是類型爲整數
<?xml version="1.0" encoding="UTF-8"?>
<extensionList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ExtensionItems.xsd">
<extensionsItem>
<extName> callCode</extName>
<extValue>1</extValue>
<extType>integer</extType>
</extensionsItem>
<extensionsItem>
<extName>callbackType</extName>
<extValue>All</extValue>
<extType>string</extType>
</extensionsItem>
<extensionsItem>
<extName>callbackEmail</extName>
<extValue>[email protected]</extValue>
<extType>string</extType>
</extensionsItem>
</extensionsList>
(它需要在XSLT被硬編碼) 用於輸入數據的XMLSCHEMA被定義爲
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="CallbackType">
<xs:restriction base="xs:string">
<xs:enumeration value="Restoration"/>
<xs:enumeration value="Estimated"/>
<xs:enumeration value="All"/>
<xs:enumeration value="None"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="ODEventNotificationExtraField">
<xs:complexType>
<xs:sequence>
<xs:element name="callCode" type="xs:integer" minOccurs="0"/>
<xs:element name="callbackType" type="CallbackType" minOccurs="0"/>
<xs:element name="callbackEmail" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
樣本輸出缺少某些開始/結束標記...例如``。如果你把它做好,我們就不必猜測實際的結構。 –
LarsH
2011-12-14 17:08:49