function ARC_rdfxml_parser::handle_open_1 in Taxonomy import/export via XML 6.2
Same name and namespace in other branches
- 5.2 arc/ARC_rdfxml_parser.php \ARC_rdfxml_parser::handle_open_1()
- 5 arc/ARC_rdfxml_parser.php \ARC_rdfxml_parser::handle_open_1()
- 6 arc/ARC_rdfxml_parser.php \ARC_rdfxml_parser::handle_open_1()
1 call to ARC_rdfxml_parser::handle_open_1()
File
- arc/
ARC_rdfxml_parser.php, line 365
Class
Code
function handle_open_1($tag, $attrs) {
$xml = "http://www.w3.org/XML/1998/namespace";
$rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
/* rdf:RDF */
if ($tag === $rdf . " RDF") {
/* lang */
$this->xml_lang = isset($attrs[$xml . " lang"]) && ($xml_lang = $attrs[$xml . " lang"]) ? $xml_lang : $this->xml_lang;
/* base */
if (isset($attrs[$xml . " base"]) && ($xml_base = $attrs[$xml . " base"])) {
$this
->set_base($xml_base);
}
return true;
}
$cur_s = array();
/* base */
if (isset($attrs[$xml . " base"]) && ($xml_base = $attrs[$xml . " base"])) {
$cur_s["xml_base"] = $this
->calc_base($xml_base);
}
elseif ($prev_s =& $this->subjs[$this->s_count - 1]) {
/* s is an o, too */
if ($p_xml_base = $prev_s["p_xml_base"]) {
$cur_s["xml_base"] = $p_xml_base;
}
elseif ($xml_base = $prev_s["xml_base"]) {
$cur_s["xml_base"] = $xml_base;
}
}
else {
/* top level node */
$cur_s["xml_base"] = $this->xml_base;
}
/* lang */
if (isset($attrs[$xml . " lang"]) && ($xml_lang = $attrs[$xml . " lang"])) {
$cur_s["xml_lang"] = $xml_lang;
}
elseif ($prev_s =& $this->subjs[$this->s_count - 1]) {
/* s is an o, too */
if ($p_xml_lang = $prev_s["p_xml_lang"]) {
$cur_s["xml_lang"] = $p_xml_lang;
}
elseif ($xml_lang = $prev_s["xml_lang"]) {
$cur_s["xml_lang"] = $xml_lang;
}
}
else {
/* top level node */
$cur_s["xml_lang"] = $this->xml_lang;
}
/* rdf:ID */
if (isset($attrs[$rdf . " ID"]) && ($rdf_id = $attrs[$rdf . " ID"])) {
$cur_s["type"] = "uri";
$cur_s["uri"] = $this
->calc_uri($cur_s, $rdf_id, "ID");
}
elseif (isset($attrs[$rdf . " about"])) {
$cur_s["type"] = "uri";
$uri = $attrs[$rdf . " about"];
$cur_s["uri"] = $this
->calc_uri($cur_s, $uri, "about");
}
else {
$cur_s["type"] = "bnode";
/* rdf:nodeID */
if (isset($attrs[$rdf . " nodeID"]) && ($rdf_nodeID = $attrs[$rdf . " nodeID"])) {
$cur_s["bnode_id"] = "_:" . $rdf_nodeID;
}
else {
/* create bnode_id */
$cur_s["bnode_id"] = $this
->create_bnode_id();
}
}
/* typed node */
if ($tag != $rdf . " Description") {
$this
->add_triple($cur_s, $rdf . "type", array(
"type" => "uri",
"uri" => str_replace(" ", "", $tag),
));
}
/* (additional) typing attr */
if (isset($attrs[$rdf . " type"]) && ($rdf_type = $attrs[$rdf . " type"])) {
$this
->add_triple($cur_s, $rdf . "type", array(
"type" => "uri",
"uri" => $rdf_type,
));
}
/* Seq|Bag|Alt */
$cur_s["li_count"] = 0;
/* rdf:li elements can exist in any description element */
if ($tag === $rdf . " Seq" || $tag === $rdf . " Bag" || $tag === $rdf . " Alt") {
$cur_s["sba"] = true;
}
/* any other attrs (qualified, but not from rdf skip_terms or xml namespace) */
$cur_lang = $this
->get_cur_lang($cur_s);
foreach ($attrs as $k => $v) {
if (strpos($k, $xml) === false && strpos($k, " ") !== false) {
if (strpos($k, $rdf) === false) {
$this
->add_triple($cur_s, str_replace(" ", "", $k), array(
"type" => "literal",
"val" => $v,
"lang" => $cur_lang,
));
}
elseif (!in_array($k, $this->skip_terms)) {
/* add, but may warn */
$this
->add_triple($cur_s, str_replace(" ", "", $k), array(
"type" => "literal",
"val" => $v,
"lang" => $cur_lang,
));
}
}
}
$this
->push_s($cur_s);
$this->state = 2;
}