declare namespace svg ="http://www.w3.org/2000/svg";
-(: TODO(#255): svg2rects.xqe doesn't support labels :)
-
-let $rects := //svg:svg/svg:rect
+let $rects := //svg:rect
+let $texts := //svg:text
+let $labels := for $text in $texts where matches($text/@id , "^label.*")
+ return concat (
+ $text/@x, " ",
+ $text/@y, " ",
+ replace($text/@style, ".*fill:#([0-9a-z]{6}).*", "$1"), " ",
+ (: TODO(#432): svg2rects doesn't handle newlines in labels :)
+ string-join($text/svg:tspan/text(), " ")
+ )
let $player := for $rect in $rects where $rect/@id = "player"
return concat (
$rect/@x, " ",
)
let $boxes := for $rect in $rects where matches($rect/@id, "^box.*")
return concat (
+ $rect/@id, " ",
$rect/@x, " ",
$rect/@y, " ",
$rect/@width, " ",
$rect/@height, " ",
replace($rect/@style, ".*fill:#([0-9a-z]{6}).*", "$1")
)
-return (
+return if (count($player) = 0) then (
+ error(QName('', 'ERROR'), 'Position of the Player is not defined. Create a rectangle with id "player"')
+) else if (count($background) = 0) then (
+ error(QName('', 'ERROR'), 'Color of the Background is not defined. Create a rectangle with id "background"')
+) else (
$background,
$player,
count($platforms),
count($backplatforms),
$backplatforms,
count($boxes),
- $boxes
+ $boxes,
+ count($labels),
+ $labels
)