2024 Aug 12 7:05 PM - edited 2024 Aug 12 7:10 PM
I need mapping help with the concat:
Source:
<root>
<SomeNode>
<SomeNode2>
<textContent>First Text</textContent>
<textContent>Second Text</textContent>
</SomeNode2>
</SomeNode>
<SomeNode>
<SomeNode2>
<textContent>First Text</textContent>
<textContent>Second Text</textContent>
</SomeNode2>
</SomeNode>
</root>
Target:
<root>
<SomeNode>
<ConcatNode>First Text, Second Text</ConcatNode>
</SomeNode>
<SomeNode>
<ConcatNode>Third Text, Forth Text</ConcatNode>
</SomeNode>
</root>
How to achieve this?
Thanks
Request clarification before answering.
I'm afraid I don't have the patience to construct XSDs to build a graphical mapping example, but here is an XSLT that will accomplish the job, and it takes much less time to get to the finish line.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="SomeNode2">
<xsl:copy>
<ConcatNode><xsl:apply-templates select="textContent"/></ConcatNode>
</xsl:copy>
</xsl:template>
<xsl:template match="textContent">
<xsl:choose>
<xsl:when test="position() != last()">
<xsl:value-of select="concat(., ', ')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ryan, I am using the graphical interface in CI. Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ryan, I am using the graphical mapping interface in CI. Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.