| 8172 | } |
| 8173 | |
| 8174 | PUGI__FN xpath_string string_value(const xpath_node& na, xpath_allocator* alloc) |
| 8175 | { |
| 8176 | if (na.attribute()) |
| 8177 | return xpath_string::from_const(na.attribute().value()); |
| 8178 | else |
| 8179 | { |
| 8180 | xml_node n = na.node(); |
| 8181 | |
| 8182 | switch (n.type()) |
| 8183 | { |
| 8184 | case node_pcdata: |
| 8185 | case node_cdata: |
| 8186 | case node_comment: |
| 8187 | case node_pi: |
| 8188 | return xpath_string::from_const(n.value()); |
| 8189 | |
| 8190 | case node_document: |
| 8191 | case node_element: |
| 8192 | { |
| 8193 | xpath_string result; |
| 8194 | |
| 8195 | // element nodes can have value if parse_embed_pcdata was used |
| 8196 | if (!n.value().empty()) |
| 8197 | result.append(xpath_string::from_const(n.value()), alloc); |
| 8198 | |
| 8199 | xml_node cur = n.first_child(); |
| 8200 | |
| 8201 | while (cur && cur != n) |
| 8202 | { |
| 8203 | if (cur.type() == node_pcdata || cur.type() == node_cdata) |
| 8204 | result.append(xpath_string::from_const(cur.value()), alloc); |
| 8205 | |
| 8206 | if (cur.first_child()) |
| 8207 | cur = cur.first_child(); |
| 8208 | else if (cur.next_sibling()) |
| 8209 | cur = cur.next_sibling(); |
| 8210 | else |
| 8211 | { |
| 8212 | while (!cur.next_sibling() && cur != n) |
| 8213 | cur = cur.parent(); |
| 8214 | |
| 8215 | if (cur != n) cur = cur.next_sibling(); |
| 8216 | } |
| 8217 | } |
| 8218 | |
| 8219 | return result; |
| 8220 | } |
| 8221 | |
| 8222 | default: |
| 8223 | return xpath_string(); |
| 8224 | } |
| 8225 | } |
| 8226 | } |
| 8227 | |
| 8228 | PUGI__FN bool node_is_before_sibling(xml_node_struct* ln, xml_node_struct* rn) |
| 8229 | { |
nothing calls this directly
no test coverage detected