2013-04-16 34 views
0

我tryng来制作复杂的映射(复杂我)与后续的情景:骡子DataMapper的字符串列表

在:

<root> 
    <bigrow> 
     <row>1</row> 
     <row>second</row> 
     <row>third</row> 
    </bigrow> 
    <bigrow> 
     <row>4</row> 
     <row>rowvalue</row> 
     <row>anotherrowvalue</row> 
    </bigrow> 
</root> 

日期:

<entities> 
    <entity> 
     <atributeA>1</atributeA> 
     <atributeB>some</atributeB> 
     <atributeC>value</atributeC> 
    </entity> 
    <entity> 
     <atributeA>2</atributeA> 
     <atributeB>another</atributeB> 
     <atributeC>valuee</atributeC> 
    </entity> 
    <entity> 
     <atributeA>3</atributeA> 
     <atributeB>ooother</atributeB> 
     <atributeC>valueee</atributeC> 
    </entity> 
</entities> 

我要地图行元素从入口顺序,所以期望的结果需要是这样的:

<entities> 
    <entity> 
     <atributeA>1</atributeA> 
     <atributeB>second</atributeB> 
     <atributeC>third</atributeC> 
    </entity> 
    <entity> 
     <atributeA>4</atributeA> 
     <atributeB>rowvalue</atributeB> 
     <atributeC>anotherrowvalue</atributeC> 
    </entity> 
</entities> 

我创建的地图制作的条目,并输出为XML,并从该两个XML和DataMapper的窗口生成模式看起来像这样:

http://i.stack.imgur.com/6CYrR.png

我不能找到如何使这项工作...如果有人可以帮助我,这可以让我快乐=)

回答

0

Mule带有XSL-T变压器,所以,如果你有兴趣,这里是转换,实现你的目标,而不使用重DataMapper的炮兵。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output method="xml" indent="yes"/> 
    <xsl:template match="/"> 
    <entities> 
     <xsl:apply-templates /> 
    </entities> 
    </xsl:template> 

    <xsl:template match="bigrow"> 
    <entity> 
     <atributeA> 
     <xsl:value-of select="child::row[position()=1]/text()" /> 
     </atributeA> 
     <atributeB> 
     <xsl:value-of select="child::row[position()=2]/text()" /> 
     </atributeB> 
     <atributeC> 
     <xsl:value-of select="child::row[position()=3]/text()" /> 
     </atributeC> 
    </entity> 
    </xsl:template> 
</xsl:stylesheet> 
+0

感谢您的快速回答,非常有用您的XSLT解决方案!但是我想使用DataMapper,因为我想知道该工具的所有功能,以便与其他产品进行一些比较,而这是我想知道的问题之一,如果我可以使用DataMapper解决并避免使用其他技术XSLT – Nicolas

+0

好点。毫无疑问,这对于DM来说是可能的。也许切换到脚本视图并使用MEL编写映射规则?希望DM用户会发出一个明确的答案。 –

相关问题