Jump to content
Sign in to follow this  
hvroosmalen

Replace element with value of another

Recommended Posts

Hello,

 

I tried to replace the value of one element with the value of a precedent.

 

 

Xml Source = Form02.xml

ArticleList with two times an Article

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <Interface>
<DatabasePath>mi-erp03sofonDevelopSPO</DatabasePath>
- <ArticleList>
- <Article>
<Description>B110.226060.101.00477 - VARICONM CONFIG 7047</Description>
<ArticleNumber>B110.226060.101.00477</ArticleNumber>
<PositionDescription>1 - B110.226060.101.00477 - VARICONM CONFIG 7047</PositionDescription>
<CostPrice>514.60</CostPrice>
<CostPriceQuantity>1.00000000</CostPriceQuantity>
<Unit>PCS</Unit>
<ListPrice>1793.18</ListPrice>
<SellPrice>1793.18</SellPrice>
<AX_IDC_ConfigId>MPQ00477_1_0_1</AX_IDC_ConfigId>
<AX_IDC_Name>B110.226060.101.00477 - VARICONM CONFIG 7047</AX_IDC_Name>
<AX_ItemName>VARICONM CONFIG 7047</AX_ItemName>
<AX_IVT_Template>SOFON-IT-VARICONM</AX_IVT_Template>
<AX_Visible>true</AX_Visible>
<GenericArticleNr>B110.226060.101.00477</GenericArticleNr>
</Article>
- <Article>
<Description>B110.226060.102.00477 - VARICONM CONFIG 7047</Description>
<ArticleNumber>B110.226060.102.00477</ArticleNumber>
<PositionDescription>1 - B110.226060.102.00477 - VARICONM CONFIG 7047</PositionDescription>
<CostPrice>514.60</CostPrice>
<CostPriceQuantity>1.00000000</CostPriceQuantity>
<Unit>PCS</Unit>
<ListPrice>1793.18</ListPrice>
<SellPrice>1793.18</SellPrice>
<AX_IDC_ConfigId>MPQ00477_1_1_2</AX_IDC_ConfigId>
<AX_IDC_Name>B110.226060.102.00477 - VARICONM CONFIG 7047</AX_IDC_Name>
<AX_ItemName>VARICONM CONFIG 7047</AX_ItemName>
<AX_IVT_Template>SOFON-IT-VARICONM</AX_IVT_Template>
<AX_Visible>false</AX_Visible>
<GenericArticleNr>B110.226060.102.00477</GenericArticleNr>
</Article>
</ArticleList>
</Interface>

 

XSL code = form02.xsl (renamed to form02xsl.txt in de Attach)

<?xml version="1.0" encoding="utf-8" ?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" encoding="UTF-8" />
<xsl:variable name="hans" />
- <xsl:template match="/">
- <Interface>
<xsl:apply-templates select="Interface/DatabasePath" />
- <ArticleList>
<xsl:apply-templates select="Interface/ArticleList/Article" />
</ArticleList>
</Interface>
</xsl:template>
- <xsl:template match="Article">
- <Article>
- <xsl:for-each select="*">
- <xsl:choose>
- <xsl:when test="name() = 'AX_IDC_ConfigId'">
- <AX_IDC_ConfigId>
<xsl:value-of select="//ArticleNumber" />
</AX_IDC_ConfigId>
</xsl:when>
- <xsl:otherwise>
- <xsl:element name="{name()}">
<xsl:value-of select="." />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</Article>
</xsl:template>
</xsl:stylesheet>

 

Result = out2.xml

<?xml version="1.0" encoding="UTF-8" ?>

- <Interface>
mi-erp03sofonDevelopSPO
- <ArticleList>
- <Article>
<Description>B110.226060.101.00477 - VARICONM CONFIG 7047</Description>
<ArticleNumber>B110.226060.101.00477</ArticleNumber>
<PositionDescription>1 - B110.226060.101.00477 - VARICONM CONFIG 7047</PositionDescription>
<CostPrice>514.60</CostPrice>
<CostPriceQuantity>1.00000000</CostPriceQuantity>
<Unit>PCS</Unit>
<ListPrice>1793.18</ListPrice>
<SellPrice>1793.18</SellPrice>
<AX_IDC_ConfigId>B110.226060.101.00477</AX_IDC_ConfigId>
<AX_IDC_Name>B110.226060.101.00477 - VARICONM CONFIG 7047</AX_IDC_Name>
<AX_ItemName>VARICONM CONFIG 7047</AX_ItemName>
<AX_IVT_Template>SOFON-IT-VARICONM</AX_IVT_Template>
<AX_Visible>true</AX_Visible>
<GenericArticleNr>B110.226060.101.00477</GenericArticleNr>
</Article>
- <Article>
<Description>B110.226060.102.00477 - VARICONM CONFIG 7047</Description>
<ArticleNumber>B110.226060.102.00477</ArticleNumber>
<PositionDescription>1 - B110.226060.102.00477 - VARICONM CONFIG 7047</PositionDescription>
<CostPrice>514.60</CostPrice>
<CostPriceQuantity>1.00000000</CostPriceQuantity>
<Unit>PCS</Unit>
<ListPrice>1793.18</ListPrice>
<SellPrice>1793.18</SellPrice>
<AX_IDC_ConfigId>B110.226060.101.00477</AX_IDC_ConfigId>
<AX_IDC_Name>B110.226060.102.00477 - VARICONM CONFIG 7047</AX_IDC_Name>
<AX_ItemName>VARICONM CONFIG 7047</AX_ItemName>
<AX_IVT_Template>SOFON-IT-VARICONM</AX_IVT_Template>
<AX_Visible>false</AX_Visible>
<GenericArticleNr>B110.226060.102.00477</GenericArticleNr>
</Article>
</ArticleList>
</Interface>
As you see the value in the second Article/AX_IDC_ConfigId element is B110.226060.101.00477 in stead of B110.226060.102.00477. How do I get the correct value in de second Article/AX_IDC_ConfigId element.
Thanks in advance
Hans van Roosmalen

 

 

post-177668-0-50965400-1413455750_thumb.jpg

From02.xml

out02.xml

From02bat.txt

From02xsl.txt

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...