[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How would I go about changing my single quotes to

Subject: Re: How would I go about changing my single quotes to double quotes in my XML output line ?
From: "Abel Braaksma (Exselt) abel@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Nov 2014 22:14:10 -0000
Re:  How would I go about changing my single quotes to
Graydon already answered you, but you might  consider some other options as
well:

1) change all double to single and all single to double-quotes
2) use a variable for the quote value (XSLT 1.0 and 2.0)
3) use a partial function application for the quoting fn:concat (XSLT 3.0)

Ex. of 1:
<xsl:value-of select='concat("""",../external_id[1],""""),   ....' />

Ex. of 2:
<xsl:variable name="quot" select=' """" ' />
<xsl:value-of select='concat($quot ,../external_id[1], $quot),   ....' />

Ex. of 3:
<xsl:variable name="quotate" select='concat("""", ?, """")' />
<xsl:value-of select='$quotate(,../external_id[1]),   ....' />

If you can use XSLT 3.0, the third option is probably easiest and removes some
of the clutter caused by all the fn:concat invocations. But you can reach the
same in XSLT 2.0 with xsl:function, it is just a bit more work.

In addition, instead of creating such big xsl:value-of statements, consider
splitting it up in smaller ones, using apply-templates on the nodes, or place
them in a sequence of items. Or, in XSLT 3.0, using Content Value Templates.
Anything that makes such large xsl:value-of statements easier to read is
probably a good thing for maintainability of the code.

Cheers,
Abel


From: Catherine Wilbur cwilbur@xxxxxxxxxxx
[mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, November 20, 2014 11:06 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  How would I go about changing my single quotes to double quotes
in my XML output line ?

Have following code in XSL stylesheet

Have string fields I surround by single quotes.  How would I change the single
quote to a double quote without getting a syntax error in the <xsl:value-of
select=.  Reason I am asking is because some of my string fields might have a
single quote embedded so I want to surround my string fields by double quotes.
With the logic below it causes a syntax error with the <xsl:value-of select="
field sytax.

Anyone have any ideas?

                 <!--
                              ===============================================
=============================================================================
====
                                Output the CSV comma delimited file with
fields in the following order:
                                  Seq#, UserId, Batch#, Vendor#, GLAcct,
Invoice#, InvoiceDate, GLDate, Currency, ExchgRate, TotInvoiceAmnt,
InvoiceLineAmnt, Attachment, PaymentTerms, Remark

                                  Remark is a combination of the unique
identifier (16 chars) plus the first 14 characters of the vendor code

                               "&#xa" is a line feed  (this is one we need to
use to generate new line)
                               "&#xD" is a carriage return

                                Note:  Amount fields and exchange rate fields
must be written out as implied decimal fields
                                =============================================
=============================================================================
======
                                -->
                              <xsl:value-of select="position(),
                                'LIBPROD',
                                local:sort-key($InvoiceCurrency,$InvoicePOLin
eOwner),
                                $Derived_FISVendorNo,
                                concat('''',../external_id[1],''''),
                                concat('''',$inv/invoice_number[1],''''),
                                concat(substring($InvoiceDateValue,5,4),subst
ring($InvoiceDateValue,1,2),substring($InvoiceDateValue,3,2)),
                                $Derived_GLDateValue,
                                $inv/invoice_amount[1]/currency[1],
                                $Derived_ExchgRate,
                                $Derived_InvoiceAmnt,
                                $Derived_InvoiceLineFundAmnt,
                                $Derived_PaymentAttachment,
                                $Derived_PaymentTerms
,
                                concat('''',$inv/unique_identifier[1],substri
ng($inv/vendor_code[1],1,14),'''')" separator=","/>
                              <xsl:text>&#xa;</xsl:text>

_____________________________________________________________________
Catherine Wilbur
  (E) cwilbur@xxxxxxxxxxx
www.uwindsor.ca/its
XSL-List info and archive
EasyUnsubscribe (by email)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.