escaping

URL encoding with XSLT 1.0

て烟熏妆下的殇ゞ 提交于 2019-12-01 17:08:32
问题 I have a problem writing my XSL. I have a link with the following code: <a> <xsl:attribute name="href"> <xsl:value-of select="concat($myUrl,'&projectNumber=',$projectNumber)"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="title"/> </xsl:attribute> LINK </a> So I need to pass a variable projectNumber to the end of myUrl . This works just fine and I get ...myUrl...&projectNumber=...projectNumber... in HTML. The problem is, that the variable projectNumber sometimes has

How to XML escaping with Apache Velocity?

允我心安 提交于 2019-12-01 16:42:23
I am generating XML using Apache Velocity. What is the best (most straight-forward) way to XML-escape the output? (I saw there is an escape tool, but could not figure out it's dev state. I also think that XML escaping is something that is very likely supported by Velocity directly.) Take a look at event handlers . eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeXmlReference Escape tool is a production ready as well if you need to escape only selective references (final version of tools was released just recently but it was in beta stage before that for 2

Echoing a tilde to a file without expanding it in Bash

萝らか妹 提交于 2019-12-01 16:41:56
I need to write an argument to a file in a Bash script, so I'm doing something like this, echo "Argument is: $1" >> file The problem is that if there's a tilde (~) in the argument I don't want it expanded to the home directory. So if the user passed ~/bin as an argument to the script, it would get written as ~/bin and not /home/user/bin. How do I do this? I assume your program is started as: $ your_prog ~/foo The argument is translated before your program is even started, so there's nothing you can do to prevent it other than educating the user to quote appropriately if the expansion is not

Escaping in groovy

纵饮孤独 提交于 2019-12-01 16:37:32
I need a help in escaping in groovy I have some string in text file like this #$commonTomcat620.max_threads$# These value i have to replace in runTime. I used following code: def str = "#\$commonTomcat620.max_threads\$#" fileContents = fileContents.replaceAll("${str}","100"); This str is printin the values as #$commonTomcat620.max_threads$#. but not replacing in file. I tried withOut #$ . it is working. Thanks. You have a couple of options to escape the dollar sign: This works (with dollar-slashy strings): def str = $/#\$$commonTomcat620.max_threads\$$#/$ Or this (with single quote strings):

Easiest way to remove unicode representations from a string in python 3?

99封情书 提交于 2019-12-01 16:32:35
问题 I have a string in python 3 that has several unicode representations in it, for example: t = 'R\\u00f3is\\u00edn' and I want to convert t so that it has the proper representation when I print it, ie: >>> print(t) Róisín However I just get the original string back. I've tried re.sub and some others, but I can't seem to find a way that will change these characters without having to iterate over each one. What would be the easiest way to do so? 回答1: You want to use the built-in codec unicode

Easiest way to remove unicode representations from a string in python 3?

荒凉一梦 提交于 2019-12-01 16:31:56
I have a string in python 3 that has several unicode representations in it, for example: t = 'R\\u00f3is\\u00edn' and I want to convert t so that it has the proper representation when I print it, ie: >>> print(t) Róisín However I just get the original string back. I've tried re.sub and some others, but I can't seem to find a way that will change these characters without having to iterate over each one. What would be the easiest way to do so? abarnert You want to use the built-in codec unicode_escape . If t is already a bytes (an 8-bit string), it's as simple as this: >>> print(t.decode(

R gsub a single double quotation mark

こ雲淡風輕ζ 提交于 2019-12-01 16:27:56
I have a field of strings in a data frame all similar to: "Young Adult – 8-9"" where the inner single " is what I want to replace with nothing to get: "Young Adult - 8-9" How can I do this? I tried to escape with a double backslash: gsub("\\"", "", string) but got this error: Error: unexpected string constant in "gsub("\"", "" You do not need to escape a double quote in a regular expression. Just use "\"" or '"' to match a single double quote. s = "Young Adult – 8-9\"" s [1] "Young Adult – 8-9\"" gsub("\"", "", s) [1] "Young Adult – 8-9" gsub('"', "", s) [1] "Young Adult – 8-9" See this IDEONE

How to XML escaping with Apache Velocity?

笑着哭i 提交于 2019-12-01 15:50:30
问题 I am generating XML using Apache Velocity. What is the best (most straight-forward) way to XML-escape the output? (I saw there is an escape tool, but could not figure out it's dev state. I also think that XML escaping is something that is very likely supported by Velocity directly.) 回答1: Take a look at event handlers. eventhandler.referenceinsertion.class = org.apache.velocity.app.event.implement.EscapeXmlReference Escape tool is a production ready as well if you need to escape only selective

simplejson.loads() get Invalid \escape: 'x'

穿精又带淫゛_ 提交于 2019-12-01 15:45:35
问题 I am learning how to use simplejson to decode JSON file. But I suffered the "invalid \escape" error. Here is the code import simplejson as json def main(): json.loads(r'{"test":"\x27"}') if __name__ == '__main__': main() And here is the error message Traceback (most recent call last): File "hello_world.py", line 7, in <module> main() File "hello_world.py", line 4, in main json.loads(r'{"test":"\x27"}') File "C:\Users\zhangkai\python\simplejson\__init__.py", line 307, in loads return _default

Getting bcp.exe to escape terminators

大兔子大兔子 提交于 2019-12-01 15:43:50
I need to export some data using SQL Server 2000's BCP utility. Sometimes my data contains characters, such as \t and \n, that I need to use as column and row terminators. How do I get BCP to escape characters it's using as terminators as it outputs the data, so that I can actually import the data in another program? For example, one of my columns is text data, and includes tabs and newlines. BCP just exports them as-is, and the program I'm trying to import them with gets confused because the data ends in the middle of a line and/or a line contains extra columns for no apparent reason. This