Specific Problem with escaping quotes in XML/Xpath
up vote
0
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
0
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
2 days ago
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
2 days ago
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
16 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
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
204
204
Are you able to use XSLT 2.0?
– Tim C
2 days ago
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
2 days ago
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
16 hours ago
add a comment |
Are you able to use XSLT 2.0?
– Tim C
2 days ago
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
2 days ago
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
16 hours ago
Are you able to use XSLT 2.0?
– Tim C
2 days ago
Are you able to use XSLT 2.0?
– Tim C
2 days ago
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
2 days ago
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
2 days ago
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
16 hours ago
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
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
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
17 hours ago
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
17 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
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
17 hours ago
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
17 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
add a comment |
up vote
1
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
17 hours ago
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
17 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
add a comment |
up vote
1
down vote
up vote
1
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 16 hours ago
answered 2 days ago
Tim C
59.1k126082
59.1k126082
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
17 hours ago
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
17 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
add a comment |
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
17 hours ago
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
17 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
17 hours ago
Still is not working..Unfortunately replace() function don't exist in Tibco BW XSLT
– Mihail Mitrevski
17 hours ago
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
17 hours ago
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
17 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
I have edited my answer to show an XSLT 1.0 solution
– Tim C
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
It worked out..thanks :)
– Mihail Mitrevski
16 hours ago
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
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
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
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
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
Are you able to use XSLT 2.0?
– Tim C
2 days ago
Yes,actualy we are using that in Tibco BW
– Mihail Mitrevski
2 days ago
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
16 hours ago