Solved

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

Posted on 2011-03-23
3
502 Views
Last Modified: 2013-11-11
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
Comment
Question by:Emanuele_Ciriachi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 256 total points
ID: 35197181
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
 
LVL 1

Author Closing Comment

by:Emanuele_Ciriachi
ID: 35230194
Thanks.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35275461
welcome
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question