[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

EASY: Parsing lists with XSL - removing that extra comma...

Greetings, I am using XSL to parse a number of records, with a rule silmilar to:
<xsl:if test="binding">
	,"binding" : {
		"field" : "<xsl:value-of select="binding/entity/field"/>"
	}
</xsl:if>

Open in new window


The problem is, I always get an extra comma, either at the end or at the beginning - which screws up my JSON parsing later.

Is there a reliable way of having a different output for the first or the last parsed element?
0
Emanuele_Ciriachi
Asked:
Emanuele_Ciriachi
  • 2
1 Solution
 
Geert BormansCommented:
totally depends on your XSLT

if you made the right apply-templates selection (meaning that only the binding parent is passed and not the white-space only text nodes as well)
you can rely on position()=1

but I need to see more of the XSL and the source XML to show you what to do
0
 
Emanuele_CiriachiAuthor Commented:
Thanks.
0
 
Geert BormansCommented:
welcome
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now