我試圖將使用通用模型發送到後端的XML表單轉換爲系統使用XSLT使用的內部XML模型。從通用模型到特定模型的XSLT轉換
通用模型由部分,行和表組成(表格基本上是一個數組/元素組)。 PK是來自tableRow的序列,而maxPK是一個計數。 MaxPK我可以在之後填充,不知道是否可以通過XSLT進行。
任何幫助,將不勝感激!
通用型號
<form>
<section>
<name>identification</name>
<sequence>1</sequence>
<line>
<sequence>0</sequence>
<field>
<name>firstName</name>
<value>JOHN</value>
</field>
</line>
<line>
<sequence>1</sequence>
<field>
<name>lastName</name>
<value>DOE</value>
</field>
</line>
</section>
<section>
<name>contactDetails</name>
<sequence>1</sequence>
<line>
<sequence>0</sequence>
<field>
<name>primaryPhone</name>
<value>+44 100 1234</value>
</field>
</line>
<table>
<name>secondaryPhoneGroup</name>
<tableRow>
<sequence>1</sequence>
<field>
<sequence>0</sequence>
<name>secondaryPhone</name>
<value>+44 100 1235</value>
</field>
</tableRow>
<tableRow>
<sequence>2</sequence>
<field>
<sequence>0</sequence>
<name>secondaryPhone</name>
<value>+44 100 1236</value>
</field>
</tableRow>
</table>
</section>
</form>
內模
<form>
<identification>
<firstName>
<asCurrent>JOHN</asCurrent>
</firstName>
<lastName>
<asCurrent>DOE</asCurrent>
</lastName>
</identification>
<contactDetails>
<primaryPhone>
<asCurrent>+44 100 1234</asCurrent>
</primaryPhone>
<secondaryPhoneGroup>
<secondaryPhone>
<pk>1</pk>
<phone>
<asCurrent>+44 100 1235</asCurrent>
</phone>
</secondaryPhone>
<secondaryPhone>
<pk>2</pk>
<phone>
<asCurrent>+44 100 1236</asCurrent>
</phone>
</secondaryPhone>
<maxPK>2</maxPK>
</secondaryPhoneGroup>
</contactDetails>
</form>
那麼,什麼是規則,你有什麼嘗試?數據的位置在哪裏來自「pk」和「maxPK」,分別是元素個數的位置? –
請將解決方案作爲答案發布,而不是更新您的問題。這是爲了避免混淆並幫助未來的訪問者。您可以在[修訂](https://stackoverflow.com/posts/44864560/revisions)中找到已刪除的解決方案。謝謝。 – Bugs