我试图将使用通用模型发送到后端的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