How do I format xslt address for xml

Questions about XML that are not covered by the other forums should go here.
kullboys
Posts: 1
Joined: Tue Jun 26, 2018 2:01 pm

How do I format xslt address for xml

Post by kullboys » Tue Jun 26, 2018 2:03 pm

Hello everyone
I have a xslt document which pulls address from an xml document. I want the output to be in separate lines like this
<AddressFullText>
542 E Main Street SE
Apartment 204B
Montreal
Onatario, Canada 99999
</AddressFullText>

How do I accomplish this?

XSLT document
Code: Select all

<AddressFullText>
<xsl:value-of select="AddressLine1"/>
<xsl:value-of select="AddressLine2"/>
<xsl:value-of select="AddressLine3"/>
<xsl:value-of select="AddressLine4"/>
</AddressFullText>
Thanks.

Radu
Posts: 6325
Joined: Fri Jul 09, 2004 5:18 pm

Re: How do I format xslt address for xml

Post by Radu » Wed Jun 27, 2018 7:31 am

Hi,

You can use xsl:text to force serialize spaces or new lines, something like:

Code: Select all

            <AddressFullText><xsl:text>
</xsl:text><xsl:value-of select="'a'"/><xsl:text>
</xsl:text><xsl:value-of select="'b'"/>
</AddressFullText>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Martin Honnen
Posts: 52
Joined: Tue Aug 19, 2014 12:04 pm

Re: How do I format xslt address for xml

Post by Martin Honnen » Wed Sep 26, 2018 4:10 pm

Assuming you use XSLT 2 or 3 (e.g. with Saxon 9) you can use

Code: Select all


<AddressFullText>
<xsl:value-of select="AddressLine1, AddressLine2, AddressLine3, AddressLine4" separator="&#10;"/>
</AddressFullText>

Post Reply