Exemplo n.º 1
0
        // 根据 use 的名称,获得可用于 API 的 use 值
        public async Task <string> GetUseValue(SruTarget target, string use_name)
        {
            var lines = await ListUses(target).ConfigureAwait(false);

            foreach (var line in lines)
            {
                if (line.Name == use_name)
                {
                    return(line.Value);
                }
                if (line.Value == use_name)
                {
                    return(line.Value);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        // 列出一个检索目标的所有可用检索途径
        public async Task <List <NameValueLine> > ListUses(SruTarget target)
        {
            List <NameValueLine> results = new List <NameValueLine>();

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

            nsmgr.AddNamespace("srw", "http://www.loc.gov/zing/srw/");
            nsmgr.AddNamespace("explain20", "http://explain.z3950.org/dtd/2.0/");
            nsmgr.AddNamespace("explain21", "http://explain.z3950.org/dtd/2.1/");

            /*
             *
             * <explain xmlns="http://explain.z3950.org/dtd/2.0/" xmlns:ns="http://explain.z3950.org/dtd/2.1/">
             * <serverInfo>
             * <ns:host>bibsys-network.alma.exlibrisgroup.com</ns:host>
             * <ns:port>80</ns:port>
             * <ns:database>47BIBSYS_NETWORK</ns:database>
             * </serverInfo>
             * <indexInfo>
             * <set name="alma" identifier="marcxml"/>
             * <index>
             * <ns:title>Accompanying Material</ns:title>
             * <map>
             * <name set="alma">accompanying_material</name>
             * </map>
             * <configInfo>
             * <supports type="relation">all</supports>
             * <supports type="relation">=</supports>
             * <supports type="emptyTerm"/>
             * </configInfo>
             * </index>
             * <index>
             * <ns:title>Additional physical form available note</ns:title>
             * <map>
             * <name set="alma">additional_physical_form_available_note</name>
             * </map>
             * <configInfo>
             * <supports type="relation">all</supports>
             * <supports type="relation">=</supports>
             * <supports type="relation">==</supports>
             * </configInfo>
             * </index>
             * */

            XmlDocument dom = await GetExplainDomAsync(target.Name,
                                                       "explain",
                                                       target.GetExplainUrl()).ConfigureAwait(false);

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("//explain20:indexInfo/explain20:index", nsmgr);

            foreach (XmlElement index in nodes)
            {
                string        title = index.SelectSingleNode("explain21:title", nsmgr)?.InnerText;
                XmlElement    map   = index.SelectSingleNode("explain20:map/explain20:name", nsmgr) as XmlElement;
                string        set   = map.GetAttribute("set");
                NameValueLine line  = new NameValueLine(title, $"{set}.{map.InnerText}");
                results.Add(line);
            }

            return(results);
        }