Specific Problem with escaping quotes in XML/Xpath
up vote
1
down vote
favorite
I have specific problem with some inbound messages that contains quotes(for example) 's-Hertogenbosch and i need to escape the first single quote because i can't inject whole node-set in the DataBase..can anyone tell me solution how can i ignore that quote?..or briefly how at all can i dynamically escape unnecessary quotes in every inbound message except first and last one.
I tryed with translate($InboundMessage, ' " ', "(blankspace)" ) and it worked fine but it removed all quotes..i need to keep first and last one..for example my Inbound message is
'Last year i visited 's-Hertogenbosch '..that single quote makes harm because on the output i got 'Last year i visited' without the name of the city.
Solution?
Regards.
xml xslt xpath tibco
add a comment |
up vote
1
down vote
favorite
I have specific problem with some inbound messages that contains quotes(for example) 's-Hertogenbosch and i need to escape the first single quote because i can't inject whole node-set in the DataBase..can anyone tell me solution how can i ignore that quote?..or briefly how at all can i dynamically escape unnecessary quotes in every inbound message except first and last one.
I tryed with translate($InboundMessage, ' " ', "(blankspace)" ) and it worked fine but it removed all quotes..i need to keep first and last one..for example my Inbound message is
'Last year i visited 's-Hertogenbosch '..that single quote makes harm because on the output i got 'Last year i visited' without the name of the city.
Solution?
Regards.
xml xslt xpath tibco
Are you able to use XSLT 2.0?
– Tim C
Nov 10 at 10:34
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
Nov 10 at 10:41
You are building the XPath expression in an external tool, right? I'm guessing "TIBCO ActiveMatrix BusinessWorks"? If that's so, does this software offer non-xpath string split and -join functions you can employ to build your expression?
– Tomalak
Nov 12 at 9:30
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have specific problem with some inbound messages that contains quotes(for example) 's-Hertogenbosch and i need to escape the first single quote because i can't inject whole node-set in the DataBase..can anyone tell me solution how can i ignore that quote?..or briefly how at all can i dynamically escape unnecessary quotes in every inbound message except first and last one.
I tryed with translate($InboundMessage, ' " ', "(blankspace)" ) and it worked fine but it removed all quotes..i need to keep first and last one..for example my Inbound message is
'Last year i visited 's-Hertogenbosch '..that single quote makes harm because on the output i got 'Last year i visited' without the name of the city.
Solution?
Regards.
xml xslt xpath tibco
I have specific problem with some inbound messages that contains quotes(for example) 's-Hertogenbosch and i need to escape the first single quote because i can't inject whole node-set in the DataBase..can anyone tell me solution how can i ignore that quote?..or briefly how at all can i dynamically escape unnecessary quotes in every inbound message except first and last one.
I tryed with translate($InboundMessage, ' " ', "(blankspace)" ) and it worked fine but it removed all quotes..i need to keep first and last one..for example my Inbound message is
'Last year i visited 's-Hertogenbosch '..that single quote makes harm because on the output i got 'Last year i visited' without the name of the city.
Solution?
Regards.
xml xslt xpath tibco
xml xslt xpath tibco
asked Nov 9 at 16:50
Mihail Mitrevski
255
255
Are you able to use XSLT 2.0?
– Tim C
Nov 10 at 10:34
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
Nov 10 at 10:41
You are building the XPath expression in an external tool, right? I'm guessing "TIBCO ActiveMatrix BusinessWorks"? If that's so, does this software offer non-xpath string split and -join functions you can employ to build your expression?
– Tomalak
Nov 12 at 9:30
add a comment |
Are you able to use XSLT 2.0?
– Tim C
Nov 10 at 10:34
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
Nov 10 at 10:41
You are building the XPath expression in an external tool, right? I'm guessing "TIBCO ActiveMatrix BusinessWorks"? If that's so, does this software offer non-xpath string split and -join functions you can employ to build your expression?
– Tomalak
Nov 12 at 9:30
Are you able to use XSLT 2.0?
– Tim C
Nov 10 at 10:34
Are you able to use XSLT 2.0?
– Tim C
Nov 10 at 10:34
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
Nov 10 at 10:41
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
Nov 10 at 10:41
You are building the XPath expression in an external tool, right? I'm guessing "TIBCO ActiveMatrix BusinessWorks"? If that's so, does this software offer non-xpath string split and -join functions you can employ to build your expression?
– Tomalak
Nov 12 at 9:30
You are building the XPath expression in an external tool, right? I'm guessing "TIBCO ActiveMatrix BusinessWorks"? If that's so, does this software offer non-xpath string split and -join functions you can employ to build your expression?
– Tomalak
Nov 12 at 9:30
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
Try this expression....
<xsl:value-of select='replace($InboundMessage, "(.)'+(.)", "$1$2")'/>
Or, if you want to do it for double quotes...
<xsl:value-of select="replace($InboundMessage, '(.)"+(.)', '$1$2')"/>
EDIT: If you can only use XSLT1.0 and XPATH 1.0, then you have to do some string manipluation
<xsl:value-of select='concat(substring($InboundMessage, 1, 1), translate(substring($InboundMessage, 2, string-length($InboundMessage) - 2), "'", ""), substring($InboundMessage, string-length($InboundMessage)))'/>
Alternatively, given your comment about building SQL, you could just replace all apostrophes, and put the outer apostrophes back in the SQL string you build
<xsl:value-of select='concat("INSERT INTO ", $Destination, " (", $Column, ") VALUES ('", translate($InboundMessage, "'", ""), "')")'/>
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Try this expression....
<xsl:value-of select='replace($InboundMessage, "(.)'+(.)", "$1$2")'/>
Or, if you want to do it for double quotes...
<xsl:value-of select="replace($InboundMessage, '(.)"+(.)', '$1$2')"/>
EDIT: If you can only use XSLT1.0 and XPATH 1.0, then you have to do some string manipluation
<xsl:value-of select='concat(substring($InboundMessage, 1, 1), translate(substring($InboundMessage, 2, string-length($InboundMessage) - 2), "'", ""), substring($InboundMessage, string-length($InboundMessage)))'/>
Alternatively, given your comment about building SQL, you could just replace all apostrophes, and put the outer apostrophes back in the SQL string you build
<xsl:value-of select='concat("INSERT INTO ", $Destination, " (", $Column, ") VALUES ('", translate($InboundMessage, "'", ""), "')")'/>
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
add a comment |
up vote
2
down vote
Try this expression....
<xsl:value-of select='replace($InboundMessage, "(.)'+(.)", "$1$2")'/>
Or, if you want to do it for double quotes...
<xsl:value-of select="replace($InboundMessage, '(.)"+(.)', '$1$2')"/>
EDIT: If you can only use XSLT1.0 and XPATH 1.0, then you have to do some string manipluation
<xsl:value-of select='concat(substring($InboundMessage, 1, 1), translate(substring($InboundMessage, 2, string-length($InboundMessage) - 2), "'", ""), substring($InboundMessage, string-length($InboundMessage)))'/>
Alternatively, given your comment about building SQL, you could just replace all apostrophes, and put the outer apostrophes back in the SQL string you build
<xsl:value-of select='concat("INSERT INTO ", $Destination, " (", $Column, ") VALUES ('", translate($InboundMessage, "'", ""), "')")'/>
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
add a comment |
up vote
2
down vote
up vote
2
down vote
Try this expression....
<xsl:value-of select='replace($InboundMessage, "(.)'+(.)", "$1$2")'/>
Or, if you want to do it for double quotes...
<xsl:value-of select="replace($InboundMessage, '(.)"+(.)', '$1$2')"/>
EDIT: If you can only use XSLT1.0 and XPATH 1.0, then you have to do some string manipluation
<xsl:value-of select='concat(substring($InboundMessage, 1, 1), translate(substring($InboundMessage, 2, string-length($InboundMessage) - 2), "'", ""), substring($InboundMessage, string-length($InboundMessage)))'/>
Alternatively, given your comment about building SQL, you could just replace all apostrophes, and put the outer apostrophes back in the SQL string you build
<xsl:value-of select='concat("INSERT INTO ", $Destination, " (", $Column, ") VALUES ('", translate($InboundMessage, "'", ""), "')")'/>
Try this expression....
<xsl:value-of select='replace($InboundMessage, "(.)'+(.)", "$1$2")'/>
Or, if you want to do it for double quotes...
<xsl:value-of select="replace($InboundMessage, '(.)"+(.)', '$1$2')"/>
EDIT: If you can only use XSLT1.0 and XPATH 1.0, then you have to do some string manipluation
<xsl:value-of select='concat(substring($InboundMessage, 1, 1), translate(substring($InboundMessage, 2, string-length($InboundMessage) - 2), "'", ""), substring($InboundMessage, string-length($InboundMessage)))'/>
Alternatively, given your comment about building SQL, you could just replace all apostrophes, and put the outer apostrophes back in the SQL string you build
<xsl:value-of select='concat("INSERT INTO ", $Destination, " (", $Column, ") VALUES ('", translate($InboundMessage, "'", ""), "')")'/>
edited Nov 12 at 9:35
answered Nov 10 at 10:56
Tim C
59.1k126082
59.1k126082
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
add a comment |
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
Nov 12 at 9:10
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I can inject this node if i use JDBC Update activity when i wrote SQL manualy with question mark and parameters for example 'INSERT INTO Destination (Column) VALUES (?)' and then in the Input just drag and drop the message...but i need to to this dynamic with SQL Direct when i need to wrote all the SQL in one sentence with variables and concatination..for example concat( 'INSERT INTO $Destination ($Column) VALUES ($InboundMessage)').... Look out..in the first example i use regular Values,and in the second example i use Variables..because of that one single quote i can't inject value in DB
– Mihail Mitrevski
Nov 12 at 9:13
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
I have edited my answer to show an XSLT 1.0 solution
– Tim C
Nov 12 at 9:23
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
It worked out..thanks :)
– Mihail Mitrevski
Nov 12 at 9:52
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230060%2fspecific-problem-with-escaping-quotes-in-xml-xpath%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you able to use XSLT 2.0?
– Tim C
Nov 10 at 10:34
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
Nov 10 at 10:41
You are building the XPath expression in an external tool, right? I'm guessing "TIBCO ActiveMatrix BusinessWorks"? If that's so, does this software offer non-xpath string split and -join functions you can employ to build your expression?
– Tomalak
Nov 12 at 9:30