Can't iterate across xlink:href attribute
Posted: Wed May 27, 2015 2:22 am
I get an error "Undeclared prefix in attribute name: xlink when I try to iterate across an xlink:href attribute and my attempts to declare the prefix either is ineffective or produces the error: "Evaluation will always throw a dynamic error: Namespace prefix" is invalid: xmlns:xlink".
I am trying to sort bibliomixed elements in bibliography in a docbook variant.
I'm using Oxygen 17.
My xquery, with one version of the attempt to declare the xlink namespace to avoid the first error, is below. (Note this code works without the xlink:href attribute on the bibliography element and without the namespace declaration. And the truth is I really don't need this attribute in that place but I do need the links on each bibliomixed element. Another problem I have is that without a declaration on the bibliography element I get a declaration on every bibliomixed element which I don't want.):
My simplified and abbreviated xml document code which does validate is:
I am trying to sort bibliomixed elements in bibliography in a docbook variant.
I'm using Oxygen 17.
My xquery, with one version of the attempt to declare the xlink namespace to avoid the first error, is below. (Note this code works without the xlink:href attribute on the bibliography element and without the namespace declaration. And the truth is I really don't need this attribute in that place but I do need the links on each bibliomixed element. Another problem I have is that without a declaration on the bibliography element I get a declaration on every bibliomixed element which I don't want.):
Code: Select all
xquery version "3.0";
declare default element namespace "http://docbook.org/ns/docbook";
declare variable $currentFile external;
let $doc := doc($currentFile)
let $bibliography := $doc/bibliography
let $new-order := (for $bib in $bibliography/bibliomixed
order by $bib//author[1]/personname/surname, $bib/pubdate[1], $bib/title[1]
return $bib )
let $new-bibliography := element bibliography {
namespace {"xmlns:xlink"} {"http://www.w3.org/1999/xlink"},
for $attr in $bibliography/@*
return
attribute {name($attr)} {$attr},
$new-order
}
return
$new-bibliography
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="file:///C:/hraf.docbook/5.0-variant-HRAFCollectionInfo/rng/hraf.docbook.rnc" type="application/relax-ng-compact-syntax"?>
<?xml-stylesheet "text/css" href="file:///C:/frameworks/hraf.docbook/css/hraf.docbook.css"?>
<bibliography xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook"
hrafid="this" ocms="113" xlink:href="http://hraf.org">
<info>
<title>BIBLIOGRAPHY</title>
</info>
<bibliomixed xlink:href="http://ehrafarchaeology.yale.edu/document?id=se49-003" xlink:show="new"
xml:id="Burger1985TheEarlyCeremonialCenterofHuaricoto">
<info>
<bibliorelation xlink:href="owc/se43"/>
</info>
<authorgroup>
<author>
<personname>
<surname>Burger</surname>, <firstname> Richard</firstname>
</personname>
</author> and <author>
<personname>
<firstname>Lucy</firstname>
<surname>Salazar-Burger</surname>
</personname>
</author>
</authorgroup> (<pubdate>1985</pubdate>). "<title>The Early Ceremonial Center of
Huaricoto</title>." In <title>
<emphasis>Early Ceremonial Architecture in the Andes: a Conference at Dumbarton Oaks, 8th
to 10th October 1982</emphasis>
</title>, <editor>
<personname>
<firstname>Christopher B.</firstname>
<surname>Donnan</surname>
</personname>
</editor>, ed. <publisher>
<publishername>Washington, D.C.: Dumbarton Oaks Research Library and
Collection</publishername>
</publisher>.</bibliomixed>
...
</bibliography>