File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
lib/sparql/query/result/formats Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,7 @@ defmodule SPARQL.Query.Result.XML.Decoder do
80
80
node |> xpath ( ~x" ./text()" s ) |> RDF.Literal . new ( language: language )
81
81
( datatype = xpath ( node , ~x" ./@datatype" s ) ) ==
82
82
"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" ->
83
- require IEx ; IEx . pry
84
- node |> xpath ( ~x" ./text()" s ) |> RDF.Literal . new ( datatype: datatype )
83
+ node |> xpath ( ~x" *" ) |> node_to_xml ( ) |> RDF.Literal . new ( datatype: datatype )
85
84
( datatype = xpath ( node , ~x" ./@datatype" s ) ) != "" ->
86
85
node |> xpath ( ~x" ./text()" s ) |> RDF.Literal . new ( datatype: datatype )
87
86
true ->
@@ -95,4 +94,13 @@ defmodule SPARQL.Query.Result.XML.Decoder do
95
94
defp decode_value ( value ) ,
96
95
do: raise "Invalid query result: #{ inspect node } "
97
96
97
+ # TODO: This is quite hacky! Is there a better solution? - https://github.com/kbrw/sweet_xml/issues/58
98
+ # TODO: Remove this when https://github.com/kbrw/sweet_xml/pull/45 gets merged
99
+ defp node_to_xml ( node ) do
100
+ [ node ]
101
+ |> :xmerl . export ( :xmerl_xml )
102
+ |> List . flatten ( )
103
+ |> List . to_string ( )
104
+ |> String . replace_leading ( ~s[ <?xml version="1.0"?>] , "" )
105
+ end
98
106
end
Original file line number Diff line number Diff line change @@ -175,7 +175,6 @@ defmodule SPARQL.Query.Result.XML.DecoderTest do
175
175
] } }
176
176
end
177
177
178
- @ tag skip: "TODO"
179
178
test "SELECT result with rdf:XMLLiteral" do
180
179
assert Query.Result.XML . decode ( """
181
180
<sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">
@@ -193,7 +192,7 @@ defmodule SPARQL.Query.Result.XML.DecoderTest do
193
192
</results>
194
193
</sparql>
195
194
""" ) == { :ok , % Query.ResultSet {
196
- variables: ~w[ x hpage name mbox age blurb friend ] ,
195
+ variables: ~w[ blurb] ,
197
196
results: [
198
197
% Query.Result { bindings: % {
199
198
"blurb" => RDF.Literal . new (
You can’t perform that action at this time.
0 commit comments