tags:

views:

223

answers:

2

I'm trying to make a mapping with this xml:

<rootxml>
  <documents>
    <document>
      <iddoc>1</iddoc>
      <total_price>1000</total_price>
    </document>
  </documents>
  <items>
    <item>
      <iddoc>1</iddoc>
      <iditem>1</iditem>
      <quantity>1</quantity>
      <price>800</price>
    </item>
    <item>
      <iddoc>1</iddoc>
      <iditem>2</iditem>
      <quantity>1</quantity>
      <price>200</price>
    </item>
  </items>
  <taxes>
    <tax>
      <iddoc>1</iddoc>
      <iditem>1</iditem>
      <idtax>1000</idtax>
      <value>123.90</value>
    <tax>
    <tax>
      <iddoc>1</iddoc>
      <iditem>2</iditem>
      <idtax>1000</idtax>
      <value>34.13</value>
    <tax>
  </taxes>
</rootxml>

to this one:

<resultxml>
  <documento>
    <iddoc>1</iddoc>
    <total_price>1000</total_price>
    <items>
      <item>
        <iddoc>1</iddoc>
        <iditem>1</iditem>
        <quantity>1</quantity>
        <price>800</price>
        <taxes>
          <idtax>1000</idtax>
          <value>123.90</value>
        </taxes>
      </item>
      <item>
        <iddoc>1</iddoc>
        <iditem>2</iditem>
        <quantity>1</quantity>
        <price>200</price>
        <taxes>
          <tax>
            <idtax>1000</idtax>
            <value>34.13</value>
          <tax>
        </taxes>
      </item>
    </items>
  </documento>
</resultxml>

I can't find out how to solve this. Although the original xml document can have several documents it will always have one, so I have to merge the items into it and taxes into its respective item.

Thank you

A: 

I think you'll have to write a chunk of custom-XSLT. Loop through items/item and then build an xpath to taxes/tax[where iditem=$itemId]. The trick is to get the first itemId into the variable.

Sorry, I have limited time right now, cannot create a full working demo for you. Here's the related issue I had a while back: http://www.stylusstudio.com/ssdn/default.asp?action=9&amp;fid=48&amp;read=7896

Neal Walters

NealWalters
A: 

Neal could you please explain in a bit detail? We have a similar situation.

Andy
Sorry, I don't think I ever see your message unless you do "Add comment" instead of adding an answer.
NealWalters