A sequence of more than one item is not allowed
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
A sequence of more than one item is not allowed
Post by DanOvergaard »
Hi,
After we have changed from XSLT 1.0 to 2.0 I have encountered a problem with a test that now return “A sequence of more than one item is not allowed as the first argument of starts-with()”
I hope some of you can guide me to the best way to solve the problem.
The XSLT is generated from this schema
Generated XSLT and the test that fails
XML
Note
I know that the test was not working as intended in XSLT 1.0 as code only checks the *first* occurrence (If I understand it correctly
After we have changed from XSLT 1.0 to 2.0 I have encountered a problem with a test that now return “A sequence of more than one item is not allowed as the first argument of starts-with()”
I hope some of you can guide me to the best way to solve the problem.
The XSLT is generated from this schema
Code: Select all
<sch:report test="starts-with(cac:Price/cac:AllowanceCharge/cbc:Amount,'-')">[F-INV335] AllowanceCharge.Amount can not be negative.</sch:report>
Code: Select all
<xsl:if test="cac:Price/cac:AllowanceCharge/starts-with(cbc:Amount,'-')">
<Error>
<xsl:attribute name="context">
<xsl:value-of select="concat(name(parent::*),'/',name())"/>
</xsl:attribute>
<Pattern>starts-with(cac:Price/cac:AllowanceCharge/cbc:Amount,'-')</Pattern>
<Description>[F-INV335] AllowanceCharge.Amount can not be negative</Description>
<Xpath>
<xsl:for-each select="ancestor-or-self::*">/<xsl:value-of select="name()"/>[<xsl:value-of select="count(preceding-sibling::*[name(.)=name(current())])+1"/>]</xsl:for-each>
</Xpath>
</Error>
Code: Select all
<cac:Price>
<cbc:PriceAmount currencyID="DKK">25.00</cbc:PriceAmount>
<cbc:BaseQuantity unitCode="EA">1</cbc:BaseQuantity>
<cbc:OrderableUnitFactorRate>1</cbc:OrderableUnitFactorRate>
<cac:AllowanceCharge>
<cbc:ID>1</cbc:ID>
<cbc:ChargeIndicator>true</cbc:ChargeIndicator>
<cbc:Amount currencyID="DKK">5.00</cbc:Amount>
</cac:AllowanceCharge>
<cac:AllowanceCharge>
<cbc:ID>2</cbc:ID>
<cbc:ChargeIndicator>false</cbc:ChargeIndicator>
<cbc:Amount currencyID="DKK">5.00</cbc:Amount>
</cac:AllowanceCharge>
</cac:Price>
I know that the test was not working as intended in XSLT 1.0 as code only checks the *first* occurrence (If I understand it correctly
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: A sequence of more than one item is not allowed
Hi,
Yes, it seems that for XSLT 1.0 the XPath expression returns the first element
I recommend you to rewrite the rule something like this:
Best Regards,
Octavian
Yes, it seems that for XSLT 1.0 the XPath expression returns the first element
I recommend you to rewrite the rule something like this:
Code: Select all
<sch:rule context="cac:Price/cac:AllowanceCharge/cbc:Amount">
<sch:report test="starts-with(., '-')">[F-INV335] AllowanceCharge.Amount can not be negative.</sch:report>
</sch:rule>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service