Reputation: 163
From the XML below, I'm trying to get the value of Value1
under the tag Agt
I'm getting below error. Please advise
Error:
A sequence of more than one item is not allowed as the first argument of fn:substring-after() ("File: 13523523362353000270", "File: 13590585000270")
XML:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns="urn:test1">
<File>
<Header>
<ID>107851</ID>
</Header>
<Detail>
<Seg>
<Agt>442REFP20210804</Agt>
<Amt>
<Value>
<Value1>File: 13523523362353000270</Value1>
</Value>
</Amt>
</Seg>
<Seg>
<Agt>EFP20210841504</Agt>
<Amt>
<Value>
<Value1>File: 13590585000270</Value1>
</Value>
</Amt>
</Seg>
</Detail>
</File>
</Document>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:cc1="urn:test1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="cc1" version="2.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- To copy the entire xml -->
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/cc1:Document/cc1:File/cc1:Detail/cc1:Seg/cc1:Agt">
<xsl:element namespace="urn:test1"
name="{local-name()}">
<xsl:value-of select="substring-after(../../cc1:Seg/cc1:Amt/cc1:Value/cc1:Value1,'File: ')"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Desired Output:
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:test1">
<File>
<Header>
<ID>107851</ID>
</Header>
<Detail>
<Seg>
<Agt>13523523362353000270</Agt>
<Amt>
<Value>
<Value1>File: 13523523362353000270</Value1>
</Value>
</Amt>
</Seg>
<Seg>
<Agt>13590585000270</Agt>
<Amt>
<Value>
<Value1>File: 13590585000270</Value1>
</Value>
</Amt>
</Seg>
</Detail>
</File>
</Document>
Upvotes: 0
Views: 114
Reputation: 167696
I guess instead of substring-after(../../cc1:Seg/cc1:Amt
you want substring-after(../cc1:Amt
.
Upvotes: 1