I have some data like that. And I want to get html.
with t(x) as (values( XMLPARSE(DOCUMENT ('<root><NotificationServiceDetails NotificationNo="0" AlarmCode="mail" AlarmStartTime="10:00:00" AlarmTime="0" Id ="2" ><NotificationServiceDetail Id="2"><Title><![CDATA[aaaaaaaaaaaaa]]></Title><ContentJson><![CDATA[
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body>
<table style="font-family: 굴림,맑은 고딕; font-size:12px;color:#333333;border-width: 1px;border-color: #ddd; border-collapse: collapse; margin:5px;width:auto; min-width:600px;">
<tbody>
<tr>
<td colspan="2" style="border-width: 1px;padding: 10px;border-style: solid;border-color: #ddd; background-color: #f5f5f5; text-align:left; font-weight:bold; font-size:13px;">aaaaaaaaaaaaa</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Writer</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Nguyen Ngo Giap (General Mgr.)</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Date</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">2022-01-04 10:00~11:00</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Schedule Div.</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">테스트함</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Content</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">aaaaaaaaaa</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Share</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;"></td>
</tr>
</tbody>
</table>
</body>
</html>
]]></ContentJson></NotificationServiceDetail></NotificationServiceDetails></root>'))))
select
unnest((xpath('//NotificationServiceDetails/NotificationServiceDetail/#Id',t.x)))::text::integer as Id,
unnest((xpath('//NotificationServiceDetails/NotificationServiceDetail/Title/text()',t.x))):: text::character varying as Title,
unnest(xpath('//NotificationServiceDetails/NotificationServiceDetail/ContentJson/text()',t.x))::xml as ContentJson,
t.x
from t;
but the ContentJson column gives me special characters. "<..." I want the real html
Expect result for column ContentJson.
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body>
<table style="font-family: 굴림,맑은 고딕; font-size:12px;color:#333333;border-width: 1px;border-color: #ddd; border-collapse: collapse; margin:5px;width:auto; min-width:600px;">
<tbody>
<tr>
<td colspan="2" style="border-width: 1px;padding: 10px;border-style: solid;border-color: #ddd; background-color: #f5f5f5; text-align:left; font-weight:bold; font-size:13px;">aaaaaaaaaaaaa</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Writer</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Nguyen Ngo Giap (General Mgr.)</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Date</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">2022-01-04 10:00~11:00</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Schedule Div.</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">테스트함</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Content</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">aaaaaaaaaa</td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;">Share</td>
<td style="padding: 15px; background-color: #f9f9f9; text-align:left;"></td>
</tr>
</tbody>
</table>
</body>
</html>
How can I do that
So far, I've provided 5 different solutions - all with their own advantages and problems - you'll have to test on your own data and hardware to ensure that it's working for you!
I did the following (all the relevant code is available on the fiddle here):
CREATE TABLE t (x TEXT);
and populated it with some text similar to yours, but shorter to making testing easier:
INSERT INTO t VALUES
($SOMETAG$with t(x) as (values( XMLPARSE(DOCUMENT ('<root><NotificationServiceDetails NotificationNo="0" AlarmCode="mail" AlarmStartTime="10:00:00" AlarmTime="0" Id ="2" ><NotificationServiceDetail Id="2"><Title><![CDATA[aaaaaaaaaaaaa]]></Title><ContentJson><![CDATA[
<html lang="en">
<head>
<meta charset="utf-8"/>
more stuff
more stuff
</table>
</body>
</html>
]]></ContentJson></NotificationServiceDetail></NotificationServiceDetails></root>'))))
select
unnest((xpath('//NotificationServiceDetails/NotificationServiceDetail/#Id',t.x)))::text::integer as Id,
unnest((xpath('//NotificationServiceDetails/NotificationServiceDetail/Title/text()',t.x))):: text::character varying as Title,
unnest(xpath('//NotificationServiceDetails/NotificationServiceDetail/ContentJson/text()',t.x))::xml as ContentJson,
t.x
from t;$SOMETAG$);
I picked up the $SOMETAG$...$SOMETAG$ technique here - very helpful for insterting characters like single quote (') and backslash (\).
There is a "one-pass" solution possible - it justs takes time patience to work it out. Oh, and BTW, there were slight errors in my orininal solution - since corrected.
Part 1:
First I remove all characters up to but not including <html lang="en"> as follows:
SELECT SUBSTRING(x, STRPOS (x,'<html lang="en"'));
SUBSTRING and STRPOS were taken from this snippet.
Part 2:
Then, I reverse that string using the REVERSE() function
Part 3:
Finally, I use the SUBSTRING/STRPOS "trick" to chop of the other end of the string to the point of <ydob>
Part 4 is the pièce de résistance
I reREVERSE() the string to bring it back to its original state - minus the undesirable bits to give the required result.
1st Solution (pretty horrible):
SELECT REVERSE(SUBSTR( REVERSE(SUBSTR(x, strpos(x, '<html lang="en">'))), strpos( REVERSE(SUBSTR(x, strpos(x, '<html lang="en">'))), '>lmth/<'))) FROM t;
It looks a bit better (or is more legible at lease):
SELECT
REVERSE(
SUBSTR(
REVERSE(
SUBSTR(x, strpos(x, '<html lang="en">'))),
strpos(
REVERSE(
SUBSTR(x, strpos(x, '<html lang="en">'))), '>lmth/<'))) FROM t;
Instead of these horrible constructions, I used CTE's (Common Table Expressions - AKA the WITH CLAUSE to do this as follows:
Code spends most of its life in maintenance, so easier to read code is easier to repair.
WITH cte1 AS
(
SELECT REVERSE(SUBSTR(x, strpos(x, '<html lang="en">'))) AS s1 FROM t
), cte2 AS
(
SELECT REVERSE(SUBSTR(s1, strpos(s1, 'ydob'))) AS s2 FROM cte1
)
SELECT * from cte2;
Result:
reverse
<html lang="en">
<head>
<meta charset="utf-8"/>
more stuff
more stuff
</table>
</body>
</html>
The answer is the same for all of them!
2nd Solution (a bit more elegant - fiddle available here):
SELECT SPLIT_PART(x, '</html>', 1) from t;
Result:
split_part
with t(x) as (values( XMLPARSE(DOCUMENT ('<root><NotificationServiceDetails NotificationNo="0" AlarmCode="mail" AlarmStartTime="10:00:00" AlarmTime="0" Id ="2" ><NotificationServiceDetail Id="2"><Title><![CDATA[aaaaaaaaaaaaa]]></Title><ContentJson><![CDATA[
<html lang="en">
<head>
<meta charset="utf-8"/>
more stuff
more stuff
</table>
</body>
<<=== Note there are 7 spaces here
So, SPLIT_PART() cuts the string up to, but not including the delimiter - </html> in this case. So, using this as follows:
So, we combine two SPLIT_PARTs in a CTE as follows:
WITH cte AS
(
SELECT LENGTH(split_part(x, '', 1)) AS beg,
LENGTH(split_part(x, '', 1)) AS fin
FROM t
)
Result:
substring
<html lang="en">
<head>
<meta charset="utf-8"/>
more stuff
more stuff
</table>
</body>
</html>
-- I cannot understand why I have to add 8 characters to the 408 of the length?
--
-- 7 (the length of </html>) I could possibly get, but why 8?
Which is the desired result.
3nd Solution (also reasonably elegant - fiddle available here):
I didn't go through all of the steps this time - I combined them all in one query. The interested reader is invited to go through it line by line.
SELECT
strpos(x, '<html lang="en">'),
strpos(x, '</html>'),
strpos(x, '</html>') - strpos(x, '<html lang="en">'),
substring(x FROM strpos(x, '<html lang="en">')
for ((strpos(x, '</html>') + 8) - strpos(x, '<html lang="en">')) )
FROM t;
--
-- Again, I'm puzzled by the necessity to use 8 characters.
--
--
Result:
strpos strpos ?column? substring
265 409 144 <html lang="en">
<head>
<meta charset="utf-8"/>
more stuff
more stuff
</table>
</body>
</html>
Et voilà - the desired result!
4th Solution (a bit convoluted, but may be instructive - fiddle available here):
1st Step:
I split the lines into records in a table as follows:
SELECT
x.idx,
LENGTH(x.string),
x.string
FROM t,
REGEXP_SPLIT_TO_TABLE(t.x, '\n') WITH ORDINALITY AS x(string, idx);
2nd step:
I pull out the records I want which correspond to the desired result as follows:
WITH cte1 AS
(
SELECT
x.idx,
LENGTH(x.string) AS ls,
x.string
FROM t,
REGEXP_SPLIT_TO_TABLE(t.x, '\n') WITH ORDINALITY AS x(string, idx)
), cte2 AS
(
SELECT idx, ls, string
FROM cte1
WHERE string ~ '<html lang="en">' OR string ~ '</html>'
ORDER BY idx
)
SELECT idx, ls, string
FROM cte1
WHERE idx BETWEEN
(SELECT MIN(idx) FROM cte2) AND (SELECT MAX(idx) FROM cte2);
Result:
idx ls string
2 22 <html lang="en">
3 12 <head>
4 33 <meta charset="utf-8"/>
5 20 more stuff
6 20 more stuff
7 16 </table>
8 13 </body>
9 14 </html>
As you can see, the string field contains the data we want!
Solution 5 - using a relatively simple regular expression - fiddle here
1st pass:
We check the output of the very handy PG_TYPEOF() function, which from the docco here does:
pg_typeof returns the OID of the data type of the value that is passed
to it. This can be helpful for troubleshooting or dynamically
constructing SQL queries. The function is declared as returning
regtype, which is an OID alias type (see Section 8.18); this means
that it is the same as an OID for comparison purposes but displays as
a type name.
So, our first query is:
SELECT
REGEXP_MATCH(x, '^.*(<head>.*</html>).*'),
PG_TYPEOF(REGEXP_MATCH(x, '^.*(<head>.*</html>).*'))
FROM t;
Result:
regexp_match pg_typeof
{"<head>
<meta charset=\"utf-8\"/>
more stuff
more stuff
</table>
</body>
</html>"} text[]
So, we have our data, but it's surrounded by braces (curly brackets) - but we know from our PG_TYPEOF() function is a text array, so we know that it's the first (only) element of that array, so therefore we can use the array element notation as follows:
SELECT
(REGEXP_MATCHES(x, '^.*(<head>.*</html>).*'))[1] -- <<-- Note [1]
FROM t;
Result:
regexp_matches
<head>
<meta charset="utf-8"/>
more stuff
more stuff
</table>
</body>
</html>
Same as the others!
Which is the same as for the others!
Crude performance analysis
After 5 runs, the order of merit appears to be the following (a fiddle of the tests run may be found here. Times will vary according to other uses to which the server may be being put, but as I said, I found them to be fairly consistent in terms of time and always in the same order on the 5 runs that I examined.
In descending order of run time:
1st) Method 3: STRPOS() Time ~ 0.045ms: - let that be a base of 1 times fastest execution
2nd) Method 1 SUBSTRING() & REVERSE() 0.079ms: x times 1.75
3rd) Method 2: SPLIT_PART() x times 2.25
4th) Method 4: REGEXP_SPLIT_TO_TABLE() WITH CTE x times 13.2
5th Method 5: REGEXP_MATCH() x times 49.4
So, we can see that the most expensive algorithm is ~ 50 times more expensive than the most efficient one. The usual caveats about benchmarking with only one record and on an unknown system apply - although the results where fairly consistent over at least 5 runs. Always benchmark on your own system with your own data!
I am new to OSM.
I have the document https://trac.openstreetmap.org/browser/subversion/applications/rendering/osmarender6/osm-map-features-z14.xml?rev=10976
This document describe set of rules for certain zoom.
There are rules that uses an image (svg) objects, e.g:
<rule e="node" k="waterway" v="lock_gate">
<wayMarker k="waterway" class="canal-lock"/>
</rule>
And there is CSS for canal-lock in the same file:
.canal-lock {
fill: none;
stroke: #ffffff;
stroke-width: 0.1px;
stroke-opacity: 0;
marker-mid: url(#canal-lock);
}
And finally, at the bottom of the document there is:
<svg:marker fill="none" id="canal-lock" markerHeight="5.9px" markerUnits="userSpaceOnUse" markerWidth="5.9px" orient="auto" refX="1px" refY="5px" stroke="#000000" stroke-width="0.75px" stroke-opacity="1" viewBox="0 0 10 10">
<svg:path d="M 1,0 L -2,5 L 1,10"/>
</svg:marker>
My Question is, Where does the canal-lock image is obtained from. i could not find that svg on the site, and my map seems to not working well since its looking for this image.
I am testing out creating a SPA using the Kendo UI Pro suite. I have an issue currently with the Kendo UI Chart (in Donut mode). The chart's SVG does not properly render in IE 10. This issue does not appear to happen in IE 11 or Firefox.
JSFiddle Example: http://jsfiddle.net/m9vq7gu4/
In the View's Show event, I call to an ajax API and get the data:
$.ajax({
url: '/echo/json/',
data: {
json: JSON.stringify({
"TotalHours": Math.random() * 714,
"Budget": 714.6
}),
delay: 2
},
type: 'POST',
success: function (response) {
console.log(response);
var data = [{
value: response.TotalHours,
color: "red"
}, {
value: response.Budget - response.TotalHours,
color: "transparent"
}];
loadRadial(id, data);
}
});
I then kendoChart the div and refresh it.
var dsRadial = new kendo.data.DataSource({
data: data
});
dsRadial.read();
var radial = $("#" + id).kendoChart({
dataSource: dsRadial,
dataBound: function () {
console.log("dataBound");
},
legend: {
visible: false
},
seriesDefaults: {
type: "donut",
holeSize: 60,
size: 20
},
series: [{
field: "value",
colorField: "color"
}],
chartArea: {
background: "transparent"
},
tooltip: {
visible: true
}
}).data("kendoChart");
I show that all events down the View/Layout/Router fire correctly. At first I thought that the chart was not binding properly, but if I look at the source code of the page the SVG is created:
<svg xmlns="http://www.w3.org/2000/svg" style="left: 0px; top: -0.47px; width: 100%; height: 100%; overflow: hidden;" version="1.1"><defs><radialGradient id="5c7e3a1b-06a7-4665-bb46-44db26b308e7" gradientUnits="userSpaceOnUse" cx="409.5" cy="100" r="80"><stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0;" offset="0.75" /><stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0.3;" offset="0.875" /><stop style="stop-color: rgb(255, 255, 255); stop-opacity: 0;" offset="0.9975" /></radialGradient></defs><g><path fill="none" stroke="none" d="M 0 0 L 819 0 L 819 200 L 0 200 Z" /><path fill="none" stroke="none" d="M 5 5 L 814 5 L 814 195 L 5 195 Z" /><g><g /></g><g><g><g transform="matrix(1 0 0 1 0 0)"><path fill="red" stroke="none" d="M 409.5 20 C 428.398 20 447.219 26.963 461.567 39.263 C 475.915 51.563 485.673 69.099 488.56 87.775 C 491.448 106.452 487.443 126.115 477.48 142.174 C 467.517 158.233 451.679 170.556 433.663 176.264 L 427.622 157.198 C 441.134 152.917 453.013 143.675 460.485 131.631 C 467.957 119.587 470.961 104.839 468.795 90.831 C 466.629 76.824 459.311 63.672 448.55 54.447 C 437.789 45.222 423.674 40 409.5 40 Z" /><path fill="url(#5c7e3a1b-06a7-4665-bb46-44db26b308e7)" stroke="none" d="M 409.5 20 C 428.398 20 447.219 26.963 461.567 39.263 C 475.915 51.563 485.673 69.099 488.56 87.775 C 491.448 106.452 487.443 126.115 477.48 142.174 C 467.517 158.233 451.679 170.556 433.663 176.264 L 427.622 157.198 C 441.134 152.917 453.013 143.675 460.485 131.631 C 467.957 119.587 470.961 104.839 468.795 90.831 C 466.629 76.824 459.311 63.672 448.55 54.447 C 437.789 45.222 423.674 40 409.5 40 Z" /></g><g transform="matrix(1 0 0 1 0 0)"><path fill="none" stroke="none" d="M 433.663 176.264 C 416.13 181.819 396.674 181.079 379.614 174.208 C 362.554 167.337 348.016 154.387 339.227 138.231 C 330.437 122.076 327.462 102.835 330.961 84.779 C 334.461 66.723 344.408 49.987 358.597 38.284 C 372.785 26.582 391.108 20 409.5 20 L 409.5 40 C 395.706 40 381.964 44.936 371.322 53.713 C 360.681 62.49 353.22 75.043 350.596 88.584 C 347.972 102.126 350.203 116.557 356.795 128.674 C 363.387 140.79 374.291 150.503 387.086 155.656 C 399.881 160.809 414.473 161.364 427.622 157.198 Z" /><path fill="url(#5c7e3a1b-06a7-4665-bb46-44db26b308e7)" stroke="none" d="M 433.663 176.264 C 416.13 181.819 396.674 181.079 379.614 174.208 C 362.554 167.337 348.016 154.387 339.227 138.231 C 330.437 122.076 327.462 102.835 330.961 84.779 C 334.461 66.723 344.408 49.987 358.597 38.284 C 372.785 26.582 391.108 20 409.5 20 L 409.5 40 C 395.706 40 381.964 44.936 371.322 53.713 C 360.681 62.49 353.22 75.043 350.596 88.584 C 347.972 102.126 350.203 116.557 356.795 128.674 C 363.387 140.79 374.291 150.503 387.086 155.656 C 399.881 160.809 414.473 161.364 427.622 157.198 Z" /></g></g></g></g></svg>
What's really odd is that as soon as I switch the router over to the other page, the SVG displays properly until the data is changed again (you can see this by clicking the Home/Data links on the demo). What could be causing this other than a weird issue between Chart and View/Layout/Router?
This is a known issue with Kendo UI prior to versions 2013.2.1215 (an internal build).
It's caused by a glitch in the IE10 SVG implementation. Once a path is scaled to 0 it disappears even if the transformation is cleared.
Hy,
so i have this:
#header
{
width: 90%;
height: auto;
margin: 0 auto 3% auto;
border-bottom: 1px solid black;
}
#header p, h1
{
display: inline;
}
#header p
{
font-style: italic;
}
h1
{
width: 40%;
border-right: 2px solid black;
font-family: Franklin Gothic Medium;
text-transform: uppercase;
font-size: 2.8em;
margin-left: 2%;
text-shadow: 0px 0px 2px white;
}
and the HTML
<div id="header">
<h1>Heading Blog Title</h1>
<p>Site description Site description Site description Site description</p></div>
It looks like this: http://i.imgur.com/TvVKjo9.jpg
But I want to keep the width of the h1 too look like this: http://i.imgur.com/YzWO8YN.jpg
Basically to center the along with the h1 tag.
Picture 1 is where i used
#header p, h1
{
display: inline;
}
for both.
In the second picture the h1 tag is positioned as i want to, but the screws it up. On the second pic I used display: inline-block; for the h1. And the p description isn't positioned in the center position, I can use margin pr padding but the rest of the description keeps going bellow the h1 tag as you can see on pic 2.
I fixed this by relative positioning and margin the p tag, but it goes bellow or above the #header in higher or smaller resolutions because I used %.
Any trick to fix this?
Thanks
Here's a jsFiddle of the above...
And one solution
Get both h1 and p to display inline-block:
#header p, h1
{
display: inline-block;
}
Float both elements left, and give #header p a width of less than 60%
Since floating removes elements from the natural document flow, you'll need to set a fixed height to the div container, so that it will still enclose the header.
Add desired margins to get the p element sitting in the right place.
A note: this won't work at smaller screen sizes, since the h1 text will stick out of it's container when it is wider than 40%. I suggest you give the h1 element a fixed width( or min-width) which you're happy with, and let #header p float to the left of it.
The webpage title on MobileSafari looks carven,host to make this effect?And what's the font family and font size of the title?
Thank you very much!
Open any iOS project in Xcode.
Launch MobileSafari in the simulator and visit google.
In Xcode, choose Product > Attach to Process > MobileSafari.
Choose Product > Debug > Pause.
In the debug console, type po [[UIApp keyWindow] recursiveDescription].
Note that this only works on the simulator. On the device, you can only attach to apps that you have installed using Xcode.
Doing all that gives you a printout of Mobile Safari's view hierarchy. Searching through it, I find this UILabel:
| | | | | <UILabel: 0x1096e800; frame = (0 0; 308 16); text = 'Google'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x1096e8c0>>
The address of the UILabel object will be different each time we do this.
Anyway, we can print that label's font like this:
(lldb) po [0x1096e800 font]
$2 = 0x0bb88110 <UICFFont: 0xbb88110> font-family: ".Helvetica NeueUI"; font-weight: bold; font-style: normal; font-size: 13px
We can print its text color:
(lldb) po [0x1096e800 textColor]
$13 = 0x1096eb50 UIDeviceRGBColorSpace 0.173 0.212 0.259 0.9
We can also print its shadow color:
(lldb) po [0x1096e800 shadowColor]
$4 = 0x1096eb70 UIDeviceWhiteColorSpace 1 0.43
Printing the shadow offset is harder, because it is a CGSize structure, not a built-in type. The debugger doesn't know about CGSize because MobileSafari doesn't include debug information. We have to give the debugger a definition. This hideous command works:
(lldb) expr -o -- typedef struct { float x; float y; } CGSize; (id)[NSValue valueWithCGSize:(CGSize)[(id)0x1096e800 shadowOffset]]
$11 = 0x08063e60 NSSize: {0, 1}
It's the system's default font, Helvetica-Neue. In UIKit, you'd get it with [UIFont systemFontOfSize:...] or [UIFont boldSystemFontOfSize:...]. The "carve" effect is a simple white drop shadow. It's achieved with the shadowColor and shadowOffset properties of UILabel.