Commit 454d3d3bc4cd45789a167dc726cbbbc6a36e08d1

Authored by Edmar Moretti
1 parent 5faef42e

Inclusão da biblioteca cswclient

pacotes/cswclient/csw-proxy.php 0 → 100644
... ... @@ -0,0 +1,115 @@
  1 +<?php
  2 +// PHP CSW Proxy for CSW services.
  3 +// Responds to both HTTP GET and POST requests
  4 +//
  5 +// Author: Rob van Swol, NLR
  6 +// October 15th, 2008
  7 +//
  8 +
  9 +$logging = false;
  10 +/* Optionally write all requests in a log file */
  11 +if ($logging) {
  12 + $fh = fopen("lib/proxy.log", "ab+");
  13 + $timestamp = strftime("[%Y-%m-%d %H:%M:%S]");
  14 +}
  15 +
  16 +$allowed_hosts = array();
  17 +
  18 +$doc = new DOMDocument();
  19 +$doc->load('./lib/xml/csw-hosts.xml');
  20 +
  21 +$hosts = $doc->getElementsByTagName("option");
  22 +foreach ($hosts as $host) {
  23 + //$csw_host_id = trim($host->nodeValue);
  24 + $csw_host = trim($host->getAttribute("value"));
  25 + //echo $csw_host."\n";
  26 + array_push($allowed_hosts, $csw_host);
  27 +}
  28 +
  29 +
  30 +// Get the REST call path from the AJAX application
  31 +// Is it a POST or a GET?
  32 +$url = ($_POST['csw_host']) ? $_POST['csw_host'] : $_GET['csw_host'];
  33 +
  34 +// Check if $url is a known host
  35 +if (!in_array($url, $allowed_hosts)) {
  36 + echo "not allowed";
  37 + if ($logging) {
  38 + fwrite($fh, $timestamp.": refused request...\n");
  39 + fwrite($fh, $timestamp.": HOST NOT ALLOWED> ".$url."\n");
  40 + }
  41 +} else {
  42 +
  43 +if ($logging) {
  44 + fwrite($fh, $timestamp.": incoming request...\n");
  45 + fwrite($fh, $timestamp.": HOST> ".$url."\n");
  46 +}
  47 +
  48 +// Open the Curl session
  49 +$session = curl_init($url);
  50 +
  51 +// If it's a POST, put the POST data in the body
  52 +if ($_POST['csw_request']) {
  53 +
  54 + //if (substr($_POST['csw_request'],0,5) == "<?xml") {
  55 + if (substr($_POST['csw_request'],0,1) == "<") {
  56 +
  57 + // Is magic quotes on?
  58 + if (get_magic_quotes_gpc())
  59 + $xmlpost = stripslashes($_POST['csw_request']);
  60 + else
  61 + $xmlpost = $_POST['csw_request'];
  62 +
  63 + curl_setopt ($session, CURLOPT_POST, true);
  64 + curl_setopt ($session, CURLOPT_POSTFIELDS, $xmlpost);
  65 + curl_setopt ($session, CURLOPT_HTTPHEADER, Array("Content-Type: application/xml"));
  66 + //curl_setopt ($session, CURLOPT_SSL_VERIFYPEER, 0);
  67 + if ($logging)
  68 + fwrite($fh, $timestamp.": POST> ".$xmlpost."\n");
  69 +
  70 + } else {
  71 + $postvars = '';
  72 + while ($element = current($_POST)) {
  73 + if (key($_POST) != "csw_request")
  74 + $postvars .= key($_POST).'='.$element.'&';
  75 + else
  76 + $postvars .= $element.'&';
  77 + next($_POST);
  78 + }
  79 + curl_setopt ($session, CURLOPT_POST, true);
  80 + curl_setopt ($session, CURLOPT_POSTFIELDS, $_POST['csw_request']);
  81 + curl_setopt ($session, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
  82 + if ($logging)
  83 + fwrite($fh, $timestamp.": POST> ".$_POST['csw_request']."\n");
  84 + }
  85 +
  86 +} else if ($_GET['csw_request']) {
  87 + curl_setopt ($session, CURLOPT_POST, true);
  88 + curl_setopt ($session, CURLOPT_POSTFIELDS, $_GET['csw_request']);
  89 + curl_setopt ($session, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
  90 + if ($logging)
  91 + fwrite($fh, $timestamp.": GET> ".$_GET['csw_request']."\n");
  92 +}
  93 +
  94 +
  95 +
  96 +// Don't return HTTP headers. Do return the contents of the call
  97 +curl_setopt($session, CURLOPT_HEADER, false);
  98 +curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  99 +
  100 +
  101 +// Make the call
  102 +$xml = curl_exec($session);
  103 +
  104 +// The web service returns XML. Set the Content-Type appropriately
  105 +header("Content-Type: text/xml");
  106 +
  107 +if ($logging) {
  108 + fwrite($fh, $timestamp.": RESPONSE> ".$xml."\n");
  109 + fclose($fh);
  110 +}
  111 +
  112 +echo $xml;
  113 +curl_close($session);
  114 +}
  115 +?>
... ...
pacotes/cswclient/csw.html 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 +<html>
  3 +<head>
  4 +<title>Simple CSW CLient</title>
  5 +<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  6 +
  7 +<link rel="stylesheet" type="text/css" href="lib/css/cswclient.css"/>
  8 +
  9 +<script type="text/javascript" src="./lib/scripts/sarissa.js"></script>
  10 +<script type="text/javascript" src="./lib/scripts/sarissa_ieemu_xpath.js"></script>
  11 +<script type="text/javascript" src="./lib/scripts/cswclient.js"></script>
  12 +
  13 +</head>
  14 +<body>
  15 +
  16 + <div class="csw-wrapper" id="csw-wrapper" style="width:80%">
  17 + <script type="text/javascript">
  18 + //var cswhost = "http://geomatics.nlr.nl/excat/csw";//default host
  19 + //var host = "http://myhost.nlr.nl/cswclient/"; // path to proxy directory if different from path to csw.html
  20 + //var csw_client = new CSWClient(cswhost, host); // if not using default settings
  21 + //var csw_client = new CSWClient("http://geonovum.nitg.tno.nl/geonetwork/srv/en/csw");
  22 + var csw_client = new CSWClient();
  23 + csw_client.writeClient("csw-wrapper");
  24 + //csw_client.useProxy(false); // default=true
  25 + </script>
  26 + </div><!-- wrapper -->
  27 +
  28 +</body>
  29 +</html>
... ...
pacotes/cswclient/excat-manual-eng.pdf 0 → 100644
No preview for this file type
pacotes/cswclient/lib/css/cswclient.css 0 → 100644
... ... @@ -0,0 +1,210 @@
  1 +/*
  2 +* File : cswclient.css
  3 +* Author : Rob van Swol
  4 +* Organisation: National Aerospace Laboratory NLR
  5 +* Country : The Netherlands
  6 +* email : vanswol@nlr.nl
  7 +* Description: CSS Stylesheet for Simple AJAX based CSW client
  8 +* Tested on : FireFox 3, Safari, IE 7
  9 +* Last Change : 2008-10-22
  10 +*/
  11 +
  12 +/* ********* csw-wrapper ************* */
  13 +.csw-wrapper {
  14 + margin: 0;
  15 + padding: 0;
  16 + font-size: 11px;
  17 + font-family: Verdana, Arial, Tahoma, Helvetica, sans-serif;
  18 + color: black;
  19 + /*min-width: 768px;*/
  20 +}
  21 +
  22 +.csw-wrapper a, .csw-wrapper a:link, .csw-wrapper a:visited, .csw-wrapper a:active {
  23 + text-decoration: none;
  24 + padding: 0px;
  25 + color: #0063D3;
  26 + /*border-bottom: 1px solid #E5ECF3;*/
  27 +}
  28 +
  29 +.csw-wrapper a:hover {
  30 + background-color: #E5ECF3;
  31 +}
  32 +
  33 +#csw-wrapper {
  34 + width: 100%;
  35 + margin: 0px auto;
  36 + clear: both;
  37 +}
  38 +
  39 +#csw-wrapper.home {
  40 + text-align: center;
  41 +}
  42 +
  43 +#csw-wrapper.home h3 {
  44 + color: #999;
  45 +}
  46 +
  47 +/* ********* clearfix ************* */
  48 +/*
  49 + Float fixer: block elements will not encompasss its child nodes
  50 + if its children are floated. Apply this class to the block element.
  51 + Not a problem in IE.
  52 +*/
  53 +
  54 +.clearfix:after {
  55 + content: ".";
  56 + display: block;
  57 + height: 0;
  58 + clear: both;
  59 + visibility: hidden;
  60 + }
  61 +
  62 +* html>body .clearfix {
  63 + display: inline-block;
  64 + width: 100%;
  65 + }
  66 +
  67 +* html .clearfix {
  68 + /* Hides from IE-mac \*/
  69 + height: 1%;
  70 + /* End hide from IE-mac */
  71 + }
  72 +
  73 +
  74 +
  75 +/* ********* main csw content************* */
  76 +
  77 +#cswclient {
  78 + clear: both;
  79 + margin-top: 1em;
  80 +}
  81 +
  82 +
  83 +.csw-main {
  84 + border: 1px solid #2e4a6b;
  85 + clear: both;
  86 + /*background: #E6ECF6;*/
  87 + background: #eef4f9;
  88 + padding-top: 2em;
  89 +}
  90 +
  91 +.csw-main2 {
  92 + border: 0px solid #2e4a6b;
  93 + clear: both;
  94 + /*background: #E6ECF6;*/
  95 + padding-top: 2em;
  96 +}
  97 +
  98 +.csw-content {
  99 + border: 1px solid #eee;
  100 + padding-left: 2em;
  101 + padding-right: 2em;
  102 + padding-bottom: 2em;
  103 + background: #eee url("images/diagonal.gif");
  104 + height: 1%;
  105 +}
  106 +
  107 +.csw-content2 {
  108 + padding-left: 2em;
  109 + padding-right: 2em;
  110 + padding-bottom: 2em;
  111 + background: #eee url("images/diagonal.gif");
  112 + height: auto;
  113 +}
  114 +
  115 +.meta
  116 + { vertical-align: top;
  117 + }
  118 +
  119 +.meta-param
  120 + { vertical-align: top;
  121 + color: #004393
  122 + }
  123 +
  124 +.meta-value
  125 + { vertical-align: top;
  126 + }
  127 +
  128 +h3 {
  129 + font-size: 1.1em;
  130 + color: #21507B;
  131 + margin-top: 0.6em;
  132 +}
  133 +
  134 +dl{ margin: 0px; padding: 0px;}
  135 +
  136 +dd{ margin: 0px; padding-left: 2em;}
  137 +
  138 +li { margin-bottom: 0.3em; }
  139 +
  140 +
  141 +
  142 +/* ********* captioneddiv************* */
  143 +
  144 +.captioneddiv
  145 + { margin: 2em 0em 0em 0em;
  146 + padding: 1em;
  147 + height:100px;
  148 + border: solid #2e4a6b 1px;
  149 + background: #ffffff;
  150 + }
  151 +
  152 +html>body .captioneddiv
  153 + { margin: 2em 0em 0em 0em;
  154 + padding: 1em;
  155 + height:auto;
  156 + border: solid #2e4a6b 1px;
  157 + background: #ffffff;
  158 + }
  159 +
  160 +.captioneddiv h3
  161 + { position: relative;
  162 + margin: 0.5em;
  163 + top: -2.0em;
  164 + left: -1.0em;
  165 + padding: 0em 0.5em;
  166 + display: inline;
  167 + font-size: 0.9em;
  168 + /*background: #cae1ff;*/
  169 + background: #ffffff;
  170 + }
  171 +
  172 +#popup
  173 + { visibility:hidden;
  174 + z-index:100;
  175 + width: 600px;
  176 + height: 500px;
  177 + left: 200px;
  178 + position: absolute;
  179 + background: #eee url("images/diagonal.gif");
  180 + border: 1px solid #2e4a6b;
  181 + }
  182 +
  183 +#popup2
  184 + { height:500px;
  185 + overflow:auto;
  186 + position: relative;
  187 + }
  188 +
  189 +.close
  190 + { position: relative;
  191 + top: 0px;
  192 + left: 0px;
  193 + padding: 3px;
  194 + color: #ffffff;
  195 + background: #2e4a6b;
  196 + z-index:101;
  197 + }
  198 +
  199 +.close a, .close a:link, .close a:visited, .close a:active .close a:hover {
  200 + text-decoration: none;
  201 + padding: 0px;
  202 + color: #ffffff;
  203 +}
  204 +
  205 +.close a:hover {
  206 + background-color: #E5ECF3;
  207 + color: #2e4a6b;
  208 + border: solid #2e4a6b 1px
  209 +}
  210 +
... ...
pacotes/cswclient/lib/css/images/diagonal.gif 0 → 100644

815 Bytes

pacotes/cswclient/lib/proxy.log 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +[2008-10-29 14:38:57]: incoming request...
  2 +[2008-10-29 14:38:57]: HOST> http://geonovum.nitg.tno.nl/geonetwork/srv/en/csw
... ...
pacotes/cswclient/lib/scripts/cswclient.js 0 → 100644
... ... @@ -0,0 +1,345 @@
  1 +/*
  2 +* File : CSWClient.js
  3 +* Author : Rob van Swol
  4 +* Organisation: National Aerospace Laboratory NLR
  5 +* Country : The Netherlands
  6 +* email : vanswol@nlr.nl
  7 +* Description: Simple AJAX based CSW client
  8 +* Depends csw-proxy.php
  9 +* Tested on : FireFox 3, Safari, IE 7
  10 +* Last Change : 2008-10-22
  11 +*/
  12 +
  13 +CSWClient = function(cswhost, host){
  14 + this.cswhost = null;
  15 + this.use_proxy = true;
  16 + if (typeof cswhost != "undefined") {
  17 + this.cswhost = cswhost;}
  18 +
  19 + this.proxy = "csw-proxy.php";
  20 + if (typeof host != "undefined") {
  21 + this.proxy = host + "csw-proxy.php";}
  22 +
  23 + this.getrecords_xsl = this.loadDocument("lib/xsl/getrecords.xsl");
  24 + this.getrecordbyid_xsl = this.loadDocument("lib/xsl/getrecordbyid.xsl");
  25 + this.defaults_xml = this.loadDocument("lib/xml/defaults.xml");
  26 + this.defaultschema = this.defaults_xml.selectSingleNode("/defaults/outputschema/text()").nodeValue;
  27 +}
  28 +
  29 +CSWClient.prototype.setCSWHost = function(host)
  30 +{
  31 + this.cswhost = host;
  32 +}
  33 +
  34 +CSWClient.prototype.useProxy = function(tf)
  35 +{
  36 + this.use_proxy = tf;
  37 +}
  38 +
  39 +CSWClient.prototype.writeClient = function(divId)
  40 +{
  41 + var client_xml = this.loadDocument("lib/xml/cswclient.xml");
  42 + /* if no default cswhost has been defined we provide the user with optional csw hosts */
  43 + if (this.cswhost == null) {
  44 + var cswhosts_xml = this.loadDocument("lib/xml/csw-hosts.xml");
  45 + var span = client_xml.selectSingleNode("//span[@id='csw-hosts']");
  46 + importNode = client_xml.importNode(cswhosts_xml.documentElement, true);
  47 + span.appendChild(importNode);
  48 + }
  49 + var serializer = new XMLSerializer();
  50 + var output = serializer.serializeToString(client_xml);
  51 + //alert (output);
  52 + var div = document.getElementById(divId);
  53 + div.innerHTML = output;
  54 +}
  55 +
  56 +CSWClient.prototype.handleCSWResponse = function(request, xml)
  57 +{
  58 +
  59 + var stylesheet = "lib/xsl/prettyxml.xsl";
  60 + if (request == "getrecords" &
  61 + document.theForm.displaymode.value != "xml") {
  62 + stylesheet = "lib/xsl/csw-results.xsl";
  63 + } else if (request == "getrecordbyid" &
  64 + document.theForm.displaymode.value != "xml") {
  65 + stylesheet = "lib/xsl/csw-metadata.xsl";
  66 + }
  67 +
  68 + xslt = this.loadDocument(stylesheet);
  69 + var processor = new XSLTProcessor();
  70 + processor.importStylesheet(xslt);
  71 +
  72 + var XmlDom = processor.transformToDocument(xml)
  73 + var serializer = new XMLSerializer();
  74 + var output = serializer.serializeToString(XmlDom.documentElement);
  75 +
  76 + var outputDiv = document.getElementById("csw-output");
  77 + if (request == "getrecordbyid"){
  78 + outputDiv = document.getElementById("metadata");
  79 + //this.positionDiv(document.getElementById('popup'), document.getElementById('results'))
  80 + //this.positionPopUp(document.getElementById('popup'), document.getElementById('results'))
  81 + this.positionPopUp(document.getElementById('popup'), document.getElementById('cswclient'))
  82 + this.showDiv(document.getElementById('popup'));
  83 + }
  84 + outputDiv.innerHTML = output;
  85 +}
  86 +
  87 +
  88 +CSWClient.prototype.getRecords = function(start)
  89 +{
  90 +
  91 + if (typeof start == "undefined") {
  92 + start = 1;}
  93 +
  94 + if (typeof document.theForm.cswhosts != "undefined") {
  95 + this.setCSWHost(document.theForm.cswhosts.value);}
  96 +
  97 + var queryable = document.theForm.queryable.value;
  98 +
  99 + /*because geonetwork doen not follow the specs*/
  100 + if(this.cswhost.indexOf('geonetwork') !=-1 & queryable == "anytext")
  101 + queryable = "any";
  102 +
  103 + var operator = document.theForm.operator.value;
  104 + var query = trim(document.theForm.query.value);
  105 + if (operator == "contains" & query != "") {query = "%" + query + "%";}
  106 +
  107 + var schema = "http://www.opengis.net/cat/csw/2.0.2"; // force outputSchema always to csw:Record for GetRecords requests
  108 + this.setXpathValue(this.defaults_xml, "/defaults/outputschema", schema + '');
  109 + this.setXpathValue(this.defaults_xml, "/defaults/propertyname", queryable + '');
  110 + this.setXpathValue(this.defaults_xml, "/defaults/literal", query + '');
  111 + //this.setXpathValue(defaults_xml, "/this.defaults/literal", query + '');
  112 + this.setXpathValue(this.defaults_xml, "/defaults/startposition", start + '');
  113 + var sortby = document.theForm.sortby.value;
  114 + this.setXpathValue(this.defaults_xml, "/defaults/sortby", sortby + '');
  115 +
  116 + var processor = new XSLTProcessor();
  117 + processor.importStylesheet(this.getrecords_xsl);
  118 +
  119 + var request_xml = processor.transformToDocument(this.defaults_xml);
  120 + var request = new XMLSerializer().serializeToString(request_xml);
  121 +
  122 + csw_response = this.sendCSWRequest(request);
  123 + var results = "<results><request start=\"" + start + "\"";
  124 + results += " maxrecords=\"";
  125 + results += this.defaults_xml.selectSingleNode("/defaults/maxrecords/text()").nodeValue;
  126 + results += "\"/></results>";
  127 +
  128 + results_xml = (new DOMParser()).parseFromString(results, "text/xml");
  129 + importNode = results_xml.importNode(csw_response.documentElement, true);
  130 + results_xml.documentElement.appendChild(importNode);
  131 + //alert(new XMLSerializer().serializeToString(results_xml));
  132 +
  133 + //return handleCSWResponse("getrecords", csw_response);
  134 + return this.handleCSWResponse("getrecords", results_xml);
  135 +}
  136 +
  137 +
  138 +CSWClient.prototype.getRecordById = function(id)
  139 +{
  140 +
  141 + var schema = this.defaultschema;
  142 + if (document.theForm.schema != null) {
  143 + schema = document.theForm.schema.value;
  144 + }
  145 +
  146 + this.setXpathValue(this.defaults_xml, "/defaults/outputschema", schema + '');
  147 + this.setXpathValue(this.defaults_xml, "/defaults/id", id + '');
  148 +
  149 + var processor = new XSLTProcessor();
  150 + processor.importStylesheet(this.getrecordbyid_xsl);
  151 +
  152 + var request_xml = processor.transformToDocument(this.defaults_xml);
  153 + var request = new XMLSerializer().serializeToString(request_xml);
  154 +
  155 + csw_response = this.sendCSWRequest(request);
  156 + //alert(new XMLSerializer().serializeToString(csw_response));
  157 + return this.handleCSWResponse("getrecordbyid", csw_response);
  158 +}
  159 +
  160 +
  161 +CSWClient.prototype.sendCSWRequest = function(request)
  162 +{
  163 +
  164 + var xml = Sarissa.getDomDocument();
  165 + xml.async = false;
  166 + var xmlhttp = new XMLHttpRequest();
  167 +
  168 + var params;
  169 + if (this.use_proxy) {
  170 + params = "csw_host=" + this.cswhost + "&csw_request=" + encodeURIComponent(request);
  171 + xmlhttp.open("POST", this.proxy, false);
  172 + xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  173 + } else {
  174 + params = request;
  175 + xmlhttp.open("POST", this.cswhost, false);
  176 + xmlhttp.setRequestHeader("Content-type", "application/xml");
  177 + }
  178 +
  179 + //xmlhttp.open("POST", this.proxy, false);
  180 + //xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  181 + //xmlhttp.open("POST", this.cswhost, false);
  182 + //xmlhttp.setRequestHeader("Content-type", "application/xml");
  183 + xmlhttp.setRequestHeader("Content-length", params.length);
  184 + xmlhttp.setRequestHeader("Connection", "close");
  185 + xmlhttp.send(params); // POST
  186 + //xmlhttp.send(''); //GET
  187 +
  188 + xml = xmlhttp.responseXML;
  189 + return xml;
  190 +}
  191 +
  192 +
  193 +CSWClient.prototype.loadDocument = function(uri)
  194 +{
  195 +
  196 + var xml = Sarissa.getDomDocument();
  197 + var xmlhttp = new XMLHttpRequest();
  198 + xml.async = false;
  199 + xmlhttp.open("GET", uri, false);
  200 + xmlhttp.send('');
  201 + xml = xmlhttp.responseXML;
  202 + return xml;
  203 +}
  204 +
  205 +
  206 +CSWClient.prototype.setXpathValue = function(_a,_b,_c)
  207 +{
  208 +
  209 + var _e=_a.selectSingleNode(_b);
  210 + if(_e){
  211 + if(_e.firstChild){
  212 + _e.firstChild.nodeValue=_c;
  213 + }else{
  214 + dom=Sarissa.getDomDocument();
  215 + v=dom.createTextNode(_c);
  216 + _e.appendChild(v);
  217 + }
  218 + return true;
  219 + }else{
  220 + return false;
  221 + }
  222 +};
  223 +
  224 +
  225 +CSWClient.prototype.clearPage = function()
  226 +{
  227 + document.theForm.query.value = "";
  228 + var outputDiv = document.getElementById("csw-output");
  229 + outputDiv.innerHTML = "";
  230 + this.hideDiv(document.getElementById('popup'))
  231 +}
  232 +
  233 +CSWClient.prototype.overlayDiv = function(div)
  234 +{
  235 + while (div.tagName !="DIV") {
  236 + div = div.parentNode
  237 + }
  238 +
  239 + _width = div.offsetWidth
  240 + _height = div.offsetHeight
  241 + _top = this.findPosY(div);
  242 + _left = this.findPosX(div);
  243 +
  244 + //overlay = document.createElement("div")
  245 + //overlay.setAttribute("id", "overlay")
  246 + var overlay = document.getElementById('overlay');
  247 + overlay.style.width = _width + "px"
  248 + overlay.style.height = _height + "px"
  249 + overlay.style.position = "absolute"
  250 + overlay.style.background = "#555555"
  251 + overlay.style.top = _top + "px"
  252 + overlay.style.left = _left + "px"
  253 +
  254 + overlay.style.filter = "alpha(opacity=70)"
  255 + overlay.style.opacity = "0.7"
  256 + overlay.style.mozOpacity = "0.7"
  257 + overlay.style.visibility="visible";
  258 +
  259 + document.getElementsByTagName("body")[0].appendChild(overlay)
  260 +}
  261 +
  262 +CSWClient.prototype.removeDiv = function(div)
  263 +{
  264 + document.getElementsByTagName("body")[0].removeChild(div)
  265 +}
  266 +
  267 +CSWClient.prototype.hideDiv = function(div)
  268 +{
  269 + document.getElementById('overlay').style.visibility="hidden";
  270 + div.style.visibility="hidden";
  271 +}
  272 +
  273 +CSWClient.prototype.showDiv = function(div)
  274 +{
  275 + //this.overlayDiv(document.getElementById('results-container'));
  276 + this.overlayDiv(document.getElementById('cswclient'));
  277 + div.style.visibility="visible";
  278 +}
  279 +
  280 +CSWClient.prototype.positionDiv = function(div1, div2)
  281 +{
  282 + var width = div2.offsetWidth-100
  283 + var height = div2.offsetHeight-100
  284 + var top = this.findPosY(div2)+50;
  285 + var left = this.findPosX(div2)+50;
  286 + div1.style.width = width + "px"
  287 + div1.style.position = "absolute"
  288 + div1.style.background = "#ffffff"
  289 + div1.style.top = top + "px"
  290 + div1.style.left = left + "px"
  291 +}
  292 +
  293 +CSWClient.prototype.positionPopUp = function(div1, div2)
  294 +{
  295 + var top = this.findPosY(div2)+50+getScrollY();
  296 + div1.style.top = top + "px"
  297 +}
  298 +
  299 +CSWClient.prototype.findPosX = function(obj)
  300 +{
  301 + var curleft = 0;
  302 + if(obj.offsetParent)
  303 + while(1) {
  304 + curleft += obj.offsetLeft;
  305 + if(!obj.offsetParent)
  306 + break;
  307 + obj = obj.offsetParent;
  308 + }
  309 + else if(obj.x)
  310 + curleft += obj.x;
  311 + return curleft;
  312 +}
  313 +
  314 +CSWClient.prototype.findPosY = function(obj)
  315 +{
  316 + var curtop = 0;
  317 + if(obj.offsetParent)
  318 + while(1) {
  319 + curtop += obj.offsetTop;
  320 + if(!obj.offsetParent)
  321 + break;
  322 + obj = obj.offsetParent;
  323 + }
  324 + else if(obj.y)
  325 + curtop += obj.y;
  326 + return curtop;
  327 +}
  328 +
  329 +function getScrollY()
  330 +{
  331 + var scrollY = 0;
  332 + if (typeof window.pageYOffset == "number") scrollY = window.pageYOffset;
  333 + else if (document.documentElement && document.documentElement.scrollTop)
  334 + scrollY = document.documentElement.scrollTop;
  335 + else if (document.body && document.body.scrollTop)
  336 + scrollY = document.body.scrollTop;
  337 + else if (window.scrollY) scrollY = window.scrollY;
  338 + return scrollY;
  339 +}
  340 +
  341 +function trim(value) {
  342 + value = value.replace(/^\s+/,'');
  343 + value = value.replace(/\s+$/,'');
  344 + return value;
  345 +}
... ...
pacotes/cswclient/lib/scripts/sarissa.js 0 → 100644
... ... @@ -0,0 +1,1025 @@
  1 +/*
  2 + * ====================================================================
  3 + * About Sarissa: http://dev.abiss.gr/sarissa
  4 + * ====================================================================
  5 + * Sarissa is an ECMAScript library acting as a cross-browser wrapper for native XML APIs.
  6 + * The library supports Gecko based browsers like Mozilla and Firefox,
  7 + * Internet Explorer (5.5+ with MSXML3.0+), Konqueror, Safari and Opera
  8 + * @version 0.9.9.4
  9 + * @author: Copyright 2004-2008 Emmanouil Batsis, mailto: mbatsis at users full stop sourceforge full stop net
  10 + * ====================================================================
  11 + * Licence
  12 + * ====================================================================
  13 + * Sarissa is free software distributed under the GNU GPL version 2 (see <a href="gpl.txt">gpl.txt</a>) or higher,
  14 + * GNU LGPL version 2.1 (see <a href="lgpl.txt">lgpl.txt</a>) or higher and Apache Software License 2.0 or higher
  15 + * (see <a href="asl.txt">asl.txt</a>). This means you can choose one of the three and use that if you like. If
  16 + * you make modifications under the ASL, i would appreciate it if you submitted those.
  17 + * In case your copy of Sarissa does not include the license texts, you may find
  18 + * them online in various formats at <a href="http://www.gnu.org">http://www.gnu.org</a> and
  19 + * <a href="http://www.apache.org">http://www.apache.org</a>.
  20 + *
  21 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  22 + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  23 + * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
  24 + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  25 + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  27 + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  28 + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29 + */
  30 +/**
  31 + * <p>Sarissa is a utility class. Provides "static" methods for DOMDocument,
  32 + * DOM Node serialization to XML strings and other utility goodies.</p>
  33 + * @constructor
  34 + * @static
  35 + */
  36 +function Sarissa(){}
  37 +Sarissa.VERSION = "0.9.9.4";
  38 +Sarissa.PARSED_OK = "Document contains no parsing errors";
  39 +Sarissa.PARSED_EMPTY = "Document is empty";
  40 +Sarissa.PARSED_UNKNOWN_ERROR = "Not well-formed or other error";
  41 +Sarissa.IS_ENABLED_TRANSFORM_NODE = false;
  42 +Sarissa.REMOTE_CALL_FLAG = "gr.abiss.sarissa.REMOTE_CALL_FLAG";
  43 +/** @private */
  44 +Sarissa._lastUniqueSuffix = 0;
  45 +/** @private */
  46 +Sarissa._getUniqueSuffix = function(){
  47 + return Sarissa._lastUniqueSuffix++;
  48 +};
  49 +/** @private */
  50 +Sarissa._SARISSA_IEPREFIX4XSLPARAM = "";
  51 +/** @private */
  52 +Sarissa._SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true;
  53 +/** @private */
  54 +Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT = Sarissa._SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
  55 +/** @private */
  56 +Sarissa._SARISSA_HAS_DOM_FEATURE = Sarissa._SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
  57 +/** @private */
  58 +Sarissa._SARISSA_IS_MOZ = Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT && Sarissa._SARISSA_HAS_DOM_FEATURE;
  59 +/** @private */
  60 +Sarissa._SARISSA_IS_SAFARI = navigator.userAgent.toLowerCase().indexOf("safari") != -1 || navigator.userAgent.toLowerCase().indexOf("konqueror") != -1;
  61 +/** @private */
  62 +Sarissa._SARISSA_IS_SAFARI_OLD = Sarissa._SARISSA_IS_SAFARI && (parseInt((navigator.userAgent.match(/AppleWebKit\/(\d+)/)||{})[1], 10) < 420);
  63 +/** @private */
  64 +Sarissa._SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
  65 +/** @private */
  66 +Sarissa._SARISSA_IS_OPERA = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
  67 +if(!window.Node || !Node.ELEMENT_NODE){
  68 + Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
  69 +}
  70 +
  71 +//This breaks for(x in o) loops in the old Safari
  72 +if(Sarissa._SARISSA_IS_SAFARI_OLD){
  73 + HTMLHtmlElement = document.createElement("html").constructor;
  74 + Node = HTMLElement = {};
  75 + HTMLElement.prototype = HTMLHtmlElement.__proto__.__proto__;
  76 + HTMLDocument = Document = document.constructor;
  77 + var x = new DOMParser();
  78 + XMLDocument = x.constructor;
  79 + Element = x.parseFromString("<Single />", "text/xml").documentElement.constructor;
  80 + x = null;
  81 +}
  82 +if(typeof XMLDocument == "undefined" && typeof Document !="undefined"){ XMLDocument = Document; }
  83 +
  84 +// IE initialization
  85 +if(Sarissa._SARISSA_IS_IE){
  86 + // for XSLT parameter names, prefix needed by IE
  87 + Sarissa._SARISSA_IEPREFIX4XSLPARAM = "xsl:";
  88 + // used to store the most recent ProgID available out of the above
  89 + var _SARISSA_DOM_PROGID = "";
  90 + var _SARISSA_XMLHTTP_PROGID = "";
  91 + var _SARISSA_DOM_XMLWRITER = "";
  92 + /**
  93 + * Called when the sarissa.js file is parsed, to pick most recent
  94 + * ProgIDs for IE, then gets destroyed.
  95 + * @memberOf Sarissa
  96 + * @private
  97 + * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
  98 + * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
  99 + */
  100 + Sarissa.pickRecentProgID = function (idList){
  101 + // found progID flag
  102 + var bFound = false, e;
  103 + var o2Store;
  104 + for(var i=0; i < idList.length && !bFound; i++){
  105 + try{
  106 + var oDoc = new ActiveXObject(idList[i]);
  107 + o2Store = idList[i];
  108 + bFound = true;
  109 + }catch (objException){
  110 + // trap; try next progID
  111 + e = objException;
  112 + }
  113 + }
  114 + if (!bFound) {
  115 + throw "Could not retrieve a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
  116 + }
  117 + idList = null;
  118 + return o2Store;
  119 + };
  120 + // pick best available MSXML progIDs
  121 + _SARISSA_DOM_PROGID = null;
  122 + _SARISSA_THREADEDDOM_PROGID = null;
  123 + _SARISSA_XSLTEMPLATE_PROGID = null;
  124 + _SARISSA_XMLHTTP_PROGID = null;
  125 + // commenting the condition out; we need to redefine XMLHttpRequest
  126 + // anyway as IE7 hardcodes it to MSXML3.0 causing version problems
  127 + // between different activex controls
  128 + //if(!window.XMLHttpRequest){
  129 + /**
  130 + * Emulate XMLHttpRequest
  131 + * @constructor
  132 + */
  133 + XMLHttpRequest = function() {
  134 + if(!_SARISSA_XMLHTTP_PROGID){
  135 + _SARISSA_XMLHTTP_PROGID = Sarissa.pickRecentProgID(["Msxml2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
  136 + }
  137 + return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
  138 + };
  139 + //}
  140 + // we dont need this anymore
  141 + //============================================
  142 + // Factory methods (IE)
  143 + //============================================
  144 + // see non-IE version
  145 + Sarissa.getDomDocument = function(sUri, sName){
  146 + if(!_SARISSA_DOM_PROGID){
  147 + _SARISSA_DOM_PROGID = Sarissa.pickRecentProgID(["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"]);
  148 + }
  149 + var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
  150 + // if a root tag name was provided, we need to load it in the DOM object
  151 + if (sName){
  152 + // create an artifical namespace prefix
  153 + // or reuse existing prefix if applicable
  154 + var prefix = "";
  155 + if(sUri){
  156 + if(sName.indexOf(":") > 1){
  157 + prefix = sName.substring(0, sName.indexOf(":"));
  158 + sName = sName.substring(sName.indexOf(":")+1);
  159 + }else{
  160 + prefix = "a" + Sarissa._getUniqueSuffix();
  161 + }
  162 + }
  163 + // use namespaces if a namespace URI exists
  164 + if(sUri){
  165 + oDoc.loadXML('<' + prefix+':'+sName + " xmlns:" + prefix + "=\"" + sUri + "\"" + " />");
  166 + } else {
  167 + oDoc.loadXML('<' + sName + " />");
  168 + }
  169 + }
  170 + return oDoc;
  171 + };
  172 + // see non-IE version
  173 + Sarissa.getParseErrorText = function (oDoc) {
  174 + var parseErrorText = Sarissa.PARSED_OK;
  175 + if(oDoc && oDoc.parseError && oDoc.parseError.errorCode && oDoc.parseError.errorCode != 0){
  176 + parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason +
  177 + "\nLocation: " + oDoc.parseError.url +
  178 + "\nLine Number " + oDoc.parseError.line + ", Column " +
  179 + oDoc.parseError.linepos +
  180 + ":\n" + oDoc.parseError.srcText +
  181 + "\n";
  182 + for(var i = 0; i < oDoc.parseError.linepos;i++){
  183 + parseErrorText += "-";
  184 + }
  185 + parseErrorText += "^\n";
  186 + }
  187 + else if(oDoc.documentElement === null){
  188 + parseErrorText = Sarissa.PARSED_EMPTY;
  189 + }
  190 + return parseErrorText;
  191 + };
  192 + // see non-IE version
  193 + Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
  194 + oDoc.setProperty("SelectionLanguage", "XPath");
  195 + oDoc.setProperty("SelectionNamespaces", sNsSet);
  196 + };
  197 + /**
  198 + * A class that reuses the same XSLT stylesheet for multiple transforms.
  199 + * @constructor
  200 + */
  201 + XSLTProcessor = function(){
  202 + if(!_SARISSA_XSLTEMPLATE_PROGID){
  203 + _SARISSA_XSLTEMPLATE_PROGID = Sarissa.pickRecentProgID(["Msxml2.XSLTemplate.6.0", "MSXML2.XSLTemplate.3.0"]);
  204 + }
  205 + this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
  206 + this.processor = null;
  207 + };
  208 + /**
  209 + * Imports the given XSLT DOM and compiles it to a reusable transform
  210 + * <b>Note:</b> If the stylesheet was loaded from a URL and contains xsl:import or xsl:include elements,it will be reloaded to resolve those
  211 + * @param {DOMDocument} xslDoc The XSLT DOMDocument to import
  212 + */
  213 + XSLTProcessor.prototype.importStylesheet = function(xslDoc){
  214 + if(!_SARISSA_THREADEDDOM_PROGID){
  215 + _SARISSA_THREADEDDOM_PROGID = Sarissa.pickRecentProgID(["MSXML2.FreeThreadedDOMDocument.6.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
  216 + }
  217 + xslDoc.setProperty("SelectionLanguage", "XPath");
  218 + xslDoc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
  219 + // convert stylesheet to free threaded
  220 + var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
  221 + // make included/imported stylesheets work if exist and xsl was originally loaded from url
  222 + try{
  223 + converted.resolveExternals = true;
  224 + converted.setProperty("AllowDocumentFunction", true);
  225 + }
  226 + catch(e){
  227 + // Ignore. "AllowDocumentFunction" is only supported in MSXML 3.0 SP4 and later.
  228 + }
  229 + if(xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null){
  230 + converted.async = false;
  231 + converted.load(xslDoc.url);
  232 + }
  233 + else {
  234 + converted.loadXML(xslDoc.xml);
  235 + }
  236 + converted.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
  237 + var output = converted.selectSingleNode("//xsl:output");
  238 + //this.outputMethod = output ? output.getAttribute("method") : "html";
  239 + if(output) {
  240 + this.outputMethod = output.getAttribute("method");
  241 + }
  242 + else {
  243 + delete this.outputMethod;
  244 + }
  245 + this.template.stylesheet = converted;
  246 + this.processor = this.template.createProcessor();
  247 + // for getParameter and clearParameters
  248 + this.paramsSet = [];
  249 + };
  250 +
  251 + /**
  252 + * Transform the given XML DOM and return the transformation result as a new DOM document
  253 + * @param {DOMDocument} sourceDoc The XML DOMDocument to transform
  254 + * @return {DOMDocument} The transformation result as a DOM Document
  255 + */
  256 + XSLTProcessor.prototype.transformToDocument = function(sourceDoc){
  257 + // fix for bug 1549749
  258 + var outDoc;
  259 + if(_SARISSA_THREADEDDOM_PROGID){
  260 + this.processor.input=sourceDoc;
  261 + outDoc=new ActiveXObject(_SARISSA_DOM_PROGID);
  262 + this.processor.output=outDoc;
  263 + this.processor.transform();
  264 + return outDoc;
  265 + }
  266 + else{
  267 + if(!_SARISSA_DOM_XMLWRITER){
  268 + _SARISSA_DOM_XMLWRITER = Sarissa.pickRecentProgID(["Msxml2.MXXMLWriter.6.0", "Msxml2.MXXMLWriter.3.0", "MSXML2.MXXMLWriter", "MSXML.MXXMLWriter", "Microsoft.XMLDOM"]);
  269 + }
  270 + this.processor.input = sourceDoc;
  271 + outDoc = new ActiveXObject(_SARISSA_DOM_XMLWRITER);
  272 + this.processor.output = outDoc;
  273 + this.processor.transform();
  274 + var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
  275 + oDoc.loadXML(outDoc.output+"");
  276 + return oDoc;
  277 + }
  278 + };
  279 +
  280 + /**
  281 + * Transform the given XML DOM and return the transformation result as a new DOM fragment.
  282 + * <b>Note</b>: The xsl:output method must match the nature of the owner document (XML/HTML).
  283 + * @param {DOMDocument} sourceDoc The XML DOMDocument to transform
  284 + * @param {DOMDocument} ownerDoc The owner of the result fragment
  285 + * @return {DOMDocument} The transformation result as a DOM Document
  286 + */
  287 + XSLTProcessor.prototype.transformToFragment = function (sourceDoc, ownerDoc) {
  288 + this.processor.input = sourceDoc;
  289 + this.processor.transform();
  290 + var s = this.processor.output;
  291 + var f = ownerDoc.createDocumentFragment();
  292 + var container;
  293 + if (this.outputMethod == 'text') {
  294 + f.appendChild(ownerDoc.createTextNode(s));
  295 + } else if (ownerDoc.body && ownerDoc.body.innerHTML) {
  296 + container = ownerDoc.createElement('div');
  297 + container.innerHTML = s;
  298 + while (container.hasChildNodes()) {
  299 + f.appendChild(container.firstChild);
  300 + }
  301 + }
  302 + else {
  303 + var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
  304 + if (s.substring(0, 5) == '<?xml') {
  305 + s = s.substring(s.indexOf('?>') + 2);
  306 + }
  307 + var xml = ''.concat('<my>', s, '</my>');
  308 + oDoc.loadXML(xml);
  309 + container = oDoc.documentElement;
  310 + while (container.hasChildNodes()) {
  311 + f.appendChild(container.firstChild);
  312 + }
  313 + }
  314 + return f;
  315 + };
  316 +
  317 + /**
  318 + * Set global XSLT parameter of the imported stylesheet
  319 + * @param {String} nsURI The parameter namespace URI
  320 + * @param {String} name The parameter base name
  321 + * @param {String} value The new parameter value
  322 + */
  323 + XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
  324 + // make value a zero length string if null to allow clearing
  325 + value = value ? value : "";
  326 + // nsURI is optional but cannot be null
  327 + if(nsURI){
  328 + this.processor.addParameter(name, value, nsURI);
  329 + }else{
  330 + this.processor.addParameter(name, value);
  331 + }
  332 + // update updated params for getParameter
  333 + nsURI = "" + (nsURI || "");
  334 + if(!this.paramsSet[nsURI]){
  335 + this.paramsSet[nsURI] = [];
  336 + }
  337 + this.paramsSet[nsURI][name] = value;
  338 + };
  339 + /**
  340 + * Gets a parameter if previously set by setParameter. Returns null
  341 + * otherwise
  342 + * @param {String} name The parameter base name
  343 + * @param {String} value The new parameter value
  344 + * @return {String} The parameter value if reviously set by setParameter, null otherwise
  345 + */
  346 + XSLTProcessor.prototype.getParameter = function(nsURI, name){
  347 + nsURI = "" + (nsURI || "");
  348 + if(this.paramsSet[nsURI] && this.paramsSet[nsURI][name]){
  349 + return this.paramsSet[nsURI][name];
  350 + }else{
  351 + return null;
  352 + }
  353 + };
  354 +
  355 + /**
  356 + * Clear parameters (set them to default values as defined in the stylesheet itself)
  357 + */
  358 + XSLTProcessor.prototype.clearParameters = function(){
  359 + for(var nsURI in this.paramsSet){
  360 + for(var name in this.paramsSet[nsURI]){
  361 + if(nsURI!=""){
  362 + this.processor.addParameter(name, "", nsURI);
  363 + }else{
  364 + this.processor.addParameter(name, "");
  365 + }
  366 + }
  367 + }
  368 + this.paramsSet = [];
  369 + };
  370 +}else{ /* end IE initialization, try to deal with real browsers now ;-) */
  371 + if(Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT){
  372 + /**
  373 + * <p>Ensures the document was loaded correctly, otherwise sets the
  374 + * parseError to -1 to indicate something went wrong. Internal use</p>
  375 + * @private
  376 + */
  377 + Sarissa.__handleLoad__ = function(oDoc){
  378 + Sarissa.__setReadyState__(oDoc, 4);
  379 + };
  380 + /**
  381 + * <p>Attached by an event handler to the load event. Internal use.</p>
  382 + * @private
  383 + */
  384 + _sarissa_XMLDocument_onload = function(){
  385 + Sarissa.__handleLoad__(this);
  386 + };
  387 + /**
  388 + * <p>Sets the readyState property of the given DOM Document object.
  389 + * Internal use.</p>
  390 + * @memberOf Sarissa
  391 + * @private
  392 + * @param oDoc the DOM Document object to fire the
  393 + * readystatechange event
  394 + * @param iReadyState the number to change the readystate property to
  395 + */
  396 + Sarissa.__setReadyState__ = function(oDoc, iReadyState){
  397 + oDoc.readyState = iReadyState;
  398 + oDoc.readystate = iReadyState;
  399 + if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") {
  400 + oDoc.onreadystatechange();
  401 + }
  402 + };
  403 +
  404 + Sarissa.getDomDocument = function(sUri, sName){
  405 + var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
  406 + if(!oDoc.onreadystatechange){
  407 +
  408 + /**
  409 + * <p>Emulate IE's onreadystatechange attribute</p>
  410 + */
  411 + oDoc.onreadystatechange = null;
  412 + }
  413 + if(!oDoc.readyState){
  414 + /**
  415 + * <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
  416 + * <ul><li>1 == LOADING,</li>
  417 + * <li>2 == LOADED,</li>
  418 + * <li>3 == INTERACTIVE,</li>
  419 + * <li>4 == COMPLETED</li></ul>
  420 + */
  421 + oDoc.readyState = 0;
  422 + }
  423 + oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
  424 + return oDoc;
  425 + };
  426 + if(window.XMLDocument){
  427 + // do nothing
  428 + }// TODO: check if the new document has content before trying to copynodes, check for error handling in DOM 3 LS
  429 + else if(Sarissa._SARISSA_HAS_DOM_FEATURE && window.Document && !Document.prototype.load && document.implementation.hasFeature('LS', '3.0')){
  430 + //Opera 9 may get the XPath branch which gives creates XMLDocument, therefore it doesn't reach here which is good
  431 + /**
  432 + * <p>Factory method to obtain a new DOM Document object</p>
  433 + * @memberOf Sarissa
  434 + * @param {String} sUri the namespace of the root node (if any)
  435 + * @param {String} sUri the local name of the root node (if any)
  436 + * @returns {DOMDOcument} a new DOM Document
  437 + */
  438 + Sarissa.getDomDocument = function(sUri, sName){
  439 + var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
  440 + return oDoc;
  441 + };
  442 + }
  443 + else {
  444 + Sarissa.getDomDocument = function(sUri, sName){
  445 + var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
  446 + // looks like safari does not create the root element for some unknown reason
  447 + if(oDoc && (sUri || sName) && !oDoc.documentElement){
  448 + oDoc.appendChild(oDoc.createElementNS(sUri, sName));
  449 + }
  450 + return oDoc;
  451 + };
  452 + }
  453 + }//if(Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT)
  454 +}
  455 +//==========================================
  456 +// Common stuff
  457 +//==========================================
  458 +if(!window.DOMParser){
  459 + if(Sarissa._SARISSA_IS_SAFARI){
  460 + /**
  461 + * DOMParser is a utility class, used to construct DOMDocuments from XML strings
  462 + * @constructor
  463 + */
  464 + DOMParser = function() { };
  465 + /**
  466 + * Construct a new DOM Document from the given XMLstring
  467 + * @param {String} sXml the given XML string
  468 + * @param {String} contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml).
  469 + * @return {DOMDocument} a new DOM Document from the given XML string
  470 + */
  471 + DOMParser.prototype.parseFromString = function(sXml, contentType){
  472 + var xmlhttp = new XMLHttpRequest();
  473 + xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false);
  474 + xmlhttp.send(null);
  475 + return xmlhttp.responseXML;
  476 + };
  477 + }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){
  478 + DOMParser = function() { };
  479 + DOMParser.prototype.parseFromString = function(sXml, contentType){
  480 + var doc = Sarissa.getDomDocument();
  481 + doc.loadXML(sXml);
  482 + return doc;
  483 + };
  484 + }
  485 +}
  486 +
  487 +if((typeof(document.importNode) == "undefined") && Sarissa._SARISSA_IS_IE){
  488 + try{
  489 + /**
  490 + * Implementation of importNode for the context window document in IE.
  491 + * If <code>oNode</code> is a TextNode, <code>bChildren</code> is ignored.
  492 + * @param {DOMNode} oNode the Node to import
  493 + * @param {boolean} bChildren whether to include the children of oNode
  494 + * @returns the imported node for further use
  495 + */
  496 + document.importNode = function(oNode, bChildren){
  497 + var tmp;
  498 + if (oNode.nodeName=='#text') {
  499 + return document.createTextNode(oNode.data);
  500 + }
  501 + else {
  502 + if(oNode.nodeName == "tbody" || oNode.nodeName == "tr"){
  503 + tmp = document.createElement("table");
  504 + }
  505 + else if(oNode.nodeName == "td"){
  506 + tmp = document.createElement("tr");
  507 + }
  508 + else if(oNode.nodeName == "option"){
  509 + tmp = document.createElement("select");
  510 + }
  511 + else{
  512 + tmp = document.createElement("div");
  513 + }
  514 + if(bChildren){
  515 + tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
  516 + }else{
  517 + tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
  518 + }
  519 + return tmp.getElementsByTagName("*")[0];
  520 + }
  521 + };
  522 + }catch(e){ }
  523 +}
  524 +if(!Sarissa.getParseErrorText){
  525 + /**
  526 + * <p>Returns a human readable description of the parsing error. Usefull
  527 + * for debugging. Tip: append the returned error string in a &lt;pre&gt;
  528 + * element if you want to render it.</p>
  529 + * <p>Many thanks to Christian Stocker for the initial patch.</p>
  530 + * @memberOf Sarissa
  531 + * @param {DOMDocument} oDoc The target DOM document
  532 + * @returns {String} The parsing error description of the target Document in
  533 + * human readable form (preformated text)
  534 + */
  535 + Sarissa.getParseErrorText = function (oDoc){
  536 + var parseErrorText = Sarissa.PARSED_OK;
  537 + if((!oDoc) || (!oDoc.documentElement)){
  538 + parseErrorText = Sarissa.PARSED_EMPTY;
  539 + } else if(oDoc.documentElement.tagName == "parsererror"){
  540 + parseErrorText = oDoc.documentElement.firstChild.data;
  541 + parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data;
  542 + } else if(oDoc.getElementsByTagName("parsererror").length > 0){
  543 + var parsererror = oDoc.getElementsByTagName("parsererror")[0];
  544 + parseErrorText = Sarissa.getText(parsererror, true)+"\n";
  545 + } else if(oDoc.parseError && oDoc.parseError.errorCode != 0){
  546 + parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
  547 + }
  548 + return parseErrorText;
  549 + };
  550 +}
  551 +/**
  552 + * Get a string with the concatenated values of all string nodes under the given node
  553 + * @param {DOMNode} oNode the given DOM node
  554 + * @param {boolean} deep whether to recursively scan the children nodes of the given node for text as well. Default is <code>false</code>
  555 + * @memberOf Sarissa
  556 + */
  557 +Sarissa.getText = function(oNode, deep){
  558 + var s = "";
  559 + var nodes = oNode.childNodes;
  560 + for(var i=0; i < nodes.length; i++){
  561 + var node = nodes[i];
  562 + var nodeType = node.nodeType;
  563 + if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
  564 + s += node.data;
  565 + } else if(deep === true && (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
  566 + s += Sarissa.getText(node, true);
  567 + }
  568 + }
  569 + return s;
  570 +};
  571 +if(!window.XMLSerializer && Sarissa.getDomDocument && Sarissa.getDomDocument("","foo", null).xml){
  572 + /**
  573 + * Utility class to serialize DOM Node objects to XML strings
  574 + * @constructor
  575 + */
  576 + XMLSerializer = function(){};
  577 + /**
  578 + * Serialize the given DOM Node to an XML string
  579 + * @param {DOMNode} oNode the DOM Node to serialize
  580 + */
  581 + XMLSerializer.prototype.serializeToString = function(oNode) {
  582 + return oNode.xml;
  583 + };
  584 +}
  585 +
  586 +/**
  587 + * Strips tags from the given markup string. If the given string is
  588 + * <code>undefined</code>, <code>null</code> or empty, it is returned as is.
  589 + * @memberOf Sarissa
  590 + * @param {String} s the string to strip the tags from
  591 + */
  592 +Sarissa.stripTags = function (s) {
  593 + return s?s.replace(/<[^>]+>/g,""):s;
  594 +};
  595 +/**
  596 + * <p>Deletes all child nodes of the given node</p>
  597 + * @memberOf Sarissa
  598 + * @param {DOMNode} oNode the Node to empty
  599 + */
  600 +Sarissa.clearChildNodes = function(oNode) {
  601 + // need to check for firstChild due to opera 8 bug with hasChildNodes
  602 + while(oNode.firstChild) {
  603 + oNode.removeChild(oNode.firstChild);
  604 + }
  605 +};
  606 +/**
  607 + * <p> Copies the childNodes of nodeFrom to nodeTo</p>
  608 + * <p> <b>Note:</b> The second object's original content is deleted before
  609 + * the copy operation, unless you supply a true third parameter</p>
  610 + * @memberOf Sarissa
  611 + * @param {DOMNode} nodeFrom the Node to copy the childNodes from
  612 + * @param {DOMNode} nodeTo the Node to copy the childNodes to
  613 + * @param {boolean} bPreserveExisting whether to preserve the original content of nodeTo, default is false
  614 + */
  615 +Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
  616 + if(Sarissa._SARISSA_IS_SAFARI && nodeTo.nodeType == Node.DOCUMENT_NODE){ // SAFARI_OLD ??
  617 + nodeTo = nodeTo.documentElement; //Apparently there's a bug in safari where you can't appendChild to a document node
  618 + }
  619 +
  620 + if((!nodeFrom) || (!nodeTo)){
  621 + throw "Both source and destination nodes must be provided";
  622 + }
  623 + if(!bPreserveExisting){
  624 + Sarissa.clearChildNodes(nodeTo);
  625 + }
  626 + var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
  627 + var nodes = nodeFrom.childNodes;
  628 + var i;
  629 + if(typeof(ownerDoc.importNode) != "undefined") {
  630 + for(i=0;i < nodes.length;i++) {
  631 + nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
  632 + }
  633 + } else {
  634 + for(i=0;i < nodes.length;i++) {
  635 + nodeTo.appendChild(nodes[i].cloneNode(true));
  636 + }
  637 + }
  638 +};
  639 +
  640 +/**
  641 + * <p> Moves the childNodes of nodeFrom to nodeTo</p>
  642 + * <p> <b>Note:</b> The second object's original content is deleted before
  643 + * the move operation, unless you supply a true third parameter</p>
  644 + * @memberOf Sarissa
  645 + * @param {DOMNode} nodeFrom the Node to copy the childNodes from
  646 + * @param {DOMNode} nodeTo the Node to copy the childNodes to
  647 + * @param {boolean} bPreserveExisting whether to preserve the original content of nodeTo, default is
  648 + */
  649 +Sarissa.moveChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
  650 + if((!nodeFrom) || (!nodeTo)){
  651 + throw "Both source and destination nodes must be provided";
  652 + }
  653 + if(!bPreserveExisting){
  654 + Sarissa.clearChildNodes(nodeTo);
  655 + }
  656 + var nodes = nodeFrom.childNodes;
  657 + // if within the same doc, just move, else copy and delete
  658 + if(nodeFrom.ownerDocument == nodeTo.ownerDocument){
  659 + while(nodeFrom.firstChild){
  660 + nodeTo.appendChild(nodeFrom.firstChild);
  661 + }
  662 + } else {
  663 + var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
  664 + var i;
  665 + if(typeof(ownerDoc.importNode) != "undefined") {
  666 + for(i=0;i < nodes.length;i++) {
  667 + nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
  668 + }
  669 + }else{
  670 + for(i=0;i < nodes.length;i++) {
  671 + nodeTo.appendChild(nodes[i].cloneNode(true));
  672 + }
  673 + }
  674 + Sarissa.clearChildNodes(nodeFrom);
  675 + }
  676 +};
  677 +
  678 +/**
  679 + * <p>Serialize any <strong>non</strong> DOM object to an XML string. All properties are serialized using the property name
  680 + * as the XML element name. Array elements are rendered as <code>array-item</code> elements,
  681 + * using their index/key as the value of the <code>key</code> attribute.</p>
  682 + * @memberOf Sarissa
  683 + * @param {Object} anyObject the object to serialize
  684 + * @param {String} objectName a name for that object, to be used as the root element name
  685 + * @return {String} the XML serialization of the given object as a string
  686 + */
  687 +Sarissa.xmlize = function(anyObject, objectName, indentSpace){
  688 + indentSpace = indentSpace?indentSpace:'';
  689 + var s = indentSpace + '<' + objectName + '>';
  690 + var isLeaf = false;
  691 + if(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String || anyObject instanceof Boolean || anyObject instanceof Date){
  692 + s += Sarissa.escape(""+anyObject);
  693 + isLeaf = true;
  694 + }else{
  695 + s += "\n";
  696 + var isArrayItem = anyObject instanceof Array;
  697 + for(var name in anyObject){
  698 + s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + " ");
  699 + }
  700 + s += indentSpace;
  701 + }
  702 + return (s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n"));
  703 +};
  704 +
  705 +/**
  706 + * Escape the given string chacters that correspond to the five predefined XML entities
  707 + * @memberOf Sarissa
  708 + * @param {String} sXml the string to escape
  709 + */
  710 +Sarissa.escape = function(sXml){
  711 + return sXml.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
  712 +};
  713 +
  714 +/**
  715 + * Unescape the given string. This turns the occurences of the predefined XML
  716 + * entities to become the characters they represent correspond to the five predefined XML entities
  717 + * @memberOf Sarissa
  718 + * @param {String}sXml the string to unescape
  719 + */
  720 +Sarissa.unescape = function(sXml){
  721 + return sXml.replace(/&apos;/g,"'").replace(/&quot;/g,"\"").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&");
  722 +};
  723 +
  724 +/** @private */
  725 +Sarissa.updateCursor = function(oTargetElement, sValue) {
  726 + if(oTargetElement && oTargetElement.style && oTargetElement.style.cursor != undefined ){
  727 + oTargetElement.style.cursor = sValue;
  728 + }
  729 +};
  730 +
  731 +/**
  732 + * Asynchronously update an element with response of a GET request on the given URL. Passing a configured XSLT
  733 + * processor will result in transforming and updating oNode before using it to update oTargetElement.
  734 + * You can also pass a callback function to be executed when the update is finished. The function will be called as
  735 + * <code>functionName(oNode, oTargetElement);</code>
  736 + * @memberOf Sarissa
  737 + * @param {String} sFromUrl the URL to make the request to
  738 + * @param {DOMElement} oTargetElement the element to update
  739 + * @param {XSLTProcessor} xsltproc (optional) the transformer to use on the returned
  740 + * content before updating the target element with it
  741 + * @param {Function} callback (optional) a Function object to execute once the update is finished successfuly, called as <code>callback(sFromUrl, oTargetElement)</code>.
  742 + * In case an exception is thrown during execution, the callback is called as called as <code>callback(sFromUrl, oTargetElement, oException)</code>
  743 + * @param {boolean} skipCache (optional) whether to skip any cache
  744 + */
  745 +Sarissa.updateContentFromURI = function(sFromUrl, oTargetElement, xsltproc, callback, skipCache) {
  746 + try{
  747 + Sarissa.updateCursor(oTargetElement, "wait");
  748 + var xmlhttp = new XMLHttpRequest();
  749 + xmlhttp.open("GET", sFromUrl, true);
  750 + xmlhttp.onreadystatechange = function() {
  751 + if (xmlhttp.readyState == 4) {
  752 + try{
  753 + var oDomDoc = xmlhttp.responseXML;
  754 + if(oDomDoc && Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
  755 + Sarissa.updateContentFromNode(xmlhttp.responseXML, oTargetElement, xsltproc);
  756 + if(callback){
  757 + callback(sFromUrl, oTargetElement);
  758 + }
  759 + }
  760 + else{
  761 + throw Sarissa.getParseErrorText(oDomDoc);
  762 + }
  763 + }
  764 + catch(e){
  765 + if(callback){
  766 + callback(sFromUrl, oTargetElement, e);
  767 + }
  768 + else{
  769 + throw e;
  770 + }
  771 + }
  772 + }
  773 + };
  774 + if (skipCache) {
  775 + var oldage = "Sat, 1 Jan 2000 00:00:00 GMT";
  776 + xmlhttp.setRequestHeader("If-Modified-Since", oldage);
  777 + }
  778 + xmlhttp.send("");
  779 + }
  780 + catch(e){
  781 + Sarissa.updateCursor(oTargetElement, "auto");
  782 + if(callback){
  783 + callback(sFromUrl, oTargetElement, e);
  784 + }
  785 + else{
  786 + throw e;
  787 + }
  788 + }
  789 +};
  790 +
  791 +/**
  792 + * Update an element's content with the given DOM node. Passing a configured XSLT
  793 + * processor will result in transforming and updating oNode before using it to update oTargetElement.
  794 + * You can also pass a callback function to be executed when the update is finished. The function will be called as
  795 + * <code>functionName(oNode, oTargetElement);</code>
  796 + * @memberOf Sarissa
  797 + * @param {DOMNode} oNode the URL to make the request to
  798 + * @param {DOMElement} oTargetElement the element to update
  799 + * @param {XSLTProcessor} xsltproc (optional) the transformer to use on the given
  800 + * DOM node before updating the target element with it
  801 + */
  802 +Sarissa.updateContentFromNode = function(oNode, oTargetElement, xsltproc) {
  803 + try {
  804 + Sarissa.updateCursor(oTargetElement, "wait");
  805 + Sarissa.clearChildNodes(oTargetElement);
  806 + // check for parsing errors
  807 + var ownerDoc = oNode.nodeType == Node.DOCUMENT_NODE?oNode:oNode.ownerDocument;
  808 + if(ownerDoc.parseError && ownerDoc.parseError.errorCode != 0) {
  809 + var pre = document.createElement("pre");
  810 + pre.appendChild(document.createTextNode(Sarissa.getParseErrorText(ownerDoc)));
  811 + oTargetElement.appendChild(pre);
  812 + }
  813 + else {
  814 + // transform if appropriate
  815 + if(xsltproc) {
  816 + oNode = xsltproc.transformToDocument(oNode);
  817 + }
  818 + // be smart, maybe the user wants to display the source instead
  819 + if(oTargetElement.tagName.toLowerCase() == "textarea" || oTargetElement.tagName.toLowerCase() == "input") {
  820 + oTargetElement.value = new XMLSerializer().serializeToString(oNode);
  821 + }
  822 + else {
  823 + // ok that was not smart; it was paranoid. Keep up the good work by trying to use DOM instead of innerHTML
  824 + try{
  825 + oTargetElement.appendChild(oTargetElement.ownerDocument.importNode(oNode, true));
  826 + }
  827 + catch(e){
  828 + oTargetElement.innerHTML = new XMLSerializer().serializeToString(oNode);
  829 + }
  830 + }
  831 + }
  832 + }
  833 + catch(e) {
  834 + throw e;
  835 + }
  836 + finally{
  837 + Sarissa.updateCursor(oTargetElement, "auto");
  838 + }
  839 +};
  840 +
  841 +
  842 +/**
  843 + * Creates an HTTP URL query string from the given HTML form data
  844 + * @memberOf Sarissa
  845 + * @param {HTMLFormElement} oForm the form to construct the query string from
  846 + */
  847 +Sarissa.formToQueryString = function(oForm){
  848 + var qs = "";
  849 + for(var i = 0;i < oForm.elements.length;i++) {
  850 + var oField = oForm.elements[i];
  851 + var sFieldName = oField.getAttribute("name") ? oField.getAttribute("name") : oField.getAttribute("id");
  852 + // ensure we got a proper name/id and that the field is not disabled
  853 + if(sFieldName &&
  854 + ((!oField.disabled) || oField.type == "hidden")) {
  855 + switch(oField.type) {
  856 + case "hidden":
  857 + case "text":
  858 + case "textarea":
  859 + case "password":
  860 + qs += sFieldName + "=" + encodeURIComponent(oField.value) + "&";
  861 + break;
  862 + case "select-one":
  863 + qs += sFieldName + "=" + encodeURIComponent(oField.options[oField.selectedIndex].value) + "&";
  864 + break;
  865 + case "select-multiple":
  866 + for (var j = 0; j < oField.length; j++) {
  867 + var optElem = oField.options[j];
  868 + if (optElem.selected === true) {
  869 + qs += sFieldName + "[]" + "=" + encodeURIComponent(optElem.value) + "&";
  870 + }
  871 + }
  872 + break;
  873 + case "checkbox":
  874 + case "radio":
  875 + if(oField.checked) {
  876 + qs += sFieldName + "=" + encodeURIComponent(oField.value) + "&";
  877 + }
  878 + break;
  879 + }
  880 + }
  881 + }
  882 + // return after removing last '&'
  883 + return qs.substr(0, qs.length - 1);
  884 +};
  885 +
  886 +
  887 +/**
  888 + * Asynchronously update an element with response of an XMLHttpRequest-based emulation of a form submission. <p>The form <code>action</code> and
  889 + * <code>method</code> attributess will be followed. Passing a configured XSLT processor will result in
  890 + * transforming and updating the server response before using it to update the target element.
  891 + * You can also pass a callback function to be executed when the update is finished. The function will be called as
  892 + * <code>functionName(oNode, oTargetElement);</code></p>
  893 + * <p>Here is an example of using this in a form element:</p>
  894 + * <pre name="code" class="xml">
  895 + * &lt;div id="targetId"&gt; this content will be updated&lt;/div&gt;
  896 + * &lt;form action="/my/form/handler" method="post"
  897 + * onbeforesubmit="return Sarissa.updateContentFromForm(this, document.getElementById('targetId'));"&gt;<pre>
  898 + * <p>If JavaScript is supported, the form will not be submitted. Instead, Sarissa will
  899 + * scan the form and make an appropriate AJAX request, also adding a parameter
  900 + * to signal to the server that this is an AJAX call. The parameter is
  901 + * constructed as <code>Sarissa.REMOTE_CALL_FLAG = "=true"</code> so you can change the name in your webpage
  902 + * simply by assigning another value to Sarissa.REMOTE_CALL_FLAG. If JavaScript is not supported
  903 + * the form will be submitted normally.
  904 + * @memberOf Sarissa
  905 + * @param {HTMLFormElement} oForm the form submition to emulate
  906 + * @param {DOMElement} oTargetElement the element to update
  907 + * @param {XSLTProcessor} xsltproc (optional) the transformer to use on the returned
  908 + * content before updating the target element with it
  909 + * @param {Function} callback (optional) a Function object to execute once the update is finished successfuly, called as <code>callback(oNode, oTargetElement)</code>.
  910 + * In case an exception occurs during excecution and a callback function was provided, the exception is cought and the callback is called as
  911 + * <code>callback(oForm, oTargetElement, exception)</code>
  912 + */
  913 +Sarissa.updateContentFromForm = function(oForm, oTargetElement, xsltproc, callback) {
  914 + try{
  915 + Sarissa.updateCursor(oTargetElement, "wait");
  916 + // build parameters from form fields
  917 + var params = Sarissa.formToQueryString(oForm) + "&" + Sarissa.REMOTE_CALL_FLAG + "=true";
  918 + var xmlhttp = new XMLHttpRequest();
  919 + var bUseGet = oForm.getAttribute("method") && oForm.getAttribute("method").toLowerCase() == "get";
  920 + if(bUseGet) {
  921 + xmlhttp.open("GET", oForm.getAttribute("action")+"?"+params, true);
  922 + }
  923 + else{
  924 + xmlhttp.open('POST', oForm.getAttribute("action"), true);
  925 + xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  926 + xmlhttp.setRequestHeader("Content-length", params.length);
  927 + xmlhttp.setRequestHeader("Connection", "close");
  928 + }
  929 + xmlhttp.onreadystatechange = function() {
  930 + try{
  931 + if (xmlhttp.readyState == 4) {
  932 + var oDomDoc = xmlhttp.responseXML;
  933 + if(oDomDoc && Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
  934 + Sarissa.updateContentFromNode(xmlhttp.responseXML, oTargetElement, xsltproc);
  935 + if(callback){
  936 + callback(oForm, oTargetElement);
  937 + }
  938 + }
  939 + else{
  940 + throw Sarissa.getParseErrorText(oDomDoc);
  941 + }
  942 + }
  943 + }
  944 + catch(e){
  945 + if(callback){
  946 + callback(oForm, oTargetElement, e);
  947 + }
  948 + else{
  949 + throw e;
  950 + }
  951 + }
  952 + };
  953 + xmlhttp.send(bUseGet?"":params);
  954 + }
  955 + catch(e){
  956 + Sarissa.updateCursor(oTargetElement, "auto");
  957 + if(callback){
  958 + callback(oForm, oTargetElement, e);
  959 + }
  960 + else{
  961 + throw e;
  962 + }
  963 + }
  964 + return false;
  965 +};
  966 +Sarissa.FUNCTION_NAME_REGEXP = new RegExp("");//new RegExp("function\\s+(\\S+)\\s*\\((.|\\n)*?\\)\\s*{");
  967 +/**
  968 + * Get the name of a function created like:
  969 + * <pre>function functionName(){}</pre>
  970 + * If a name is not found and the bForce parameter is true,
  971 + * attach the function to the window object with a new name and
  972 + * return that
  973 + * @param {Function} oFunc the function object
  974 + * @param {boolean} bForce whether to force a name under the window context if none is found
  975 + */
  976 +Sarissa.getFunctionName = function(oFunc, bForce){
  977 + //alert("Sarissa.getFunctionName oFunc: "+oFunc);
  978 + var name;
  979 + if(!name){
  980 + if(bForce){
  981 + // attach to window object under a new name
  982 + name = "SarissaAnonymous" + Sarissa._getUniqueSuffix();
  983 + window[name] = oFunc;
  984 + }
  985 + else{
  986 + name = null;
  987 + }
  988 + }
  989 +
  990 + //alert("Sarissa.getFunctionName returns: "+name);
  991 + if(name){
  992 + window[name] = oFunc;
  993 + }
  994 + return name;
  995 +};
  996 +
  997 +/**
  998 + *
  999 + */
  1000 +Sarissa.setRemoteJsonCallback = function(url, callback, callbackParam) {
  1001 + if(!callbackParam){
  1002 + callbackParam = "callback";
  1003 + }
  1004 + var callbackFunctionName = Sarissa.getFunctionName(callback, true);
  1005 + var id = "sarissa_json_script_id_" + Sarissa._getUniqueSuffix();
  1006 + var oHead = document.getElementsByTagName("head")[0];
  1007 + var scriptTag = document.createElement('script');
  1008 + scriptTag.type = 'text/javascript';
  1009 + scriptTag.id = id;
  1010 + scriptTag.onload = function(){
  1011 + // cleanUp
  1012 + // document.removeChild(scriptTag);
  1013 + };
  1014 + if(url.indexOf("?") != -1){
  1015 + url += ("&" + callbackParam + "=" + callbackFunctionName);
  1016 + }
  1017 + else{
  1018 + url += ("?" + callbackParam + "=" + callbackFunctionName);
  1019 + }
  1020 + scriptTag.src = url;
  1021 + oHead.appendChild(scriptTag);
  1022 + return id;
  1023 +};
  1024 +
  1025 +// EOF
... ...
pacotes/cswclient/lib/scripts/sarissa_ieemu_xpath.js 0 → 100644
... ... @@ -0,0 +1,220 @@
  1 +/**
  2 + * ====================================================================
  3 + * About
  4 + * ====================================================================
  5 + * Sarissa cross browser XML library - IE XPath Emulation
  6 + * @version 0.9.9.4
  7 + * @author: Copyright 2004-2007 Emmanouil Batsis, mailto: mbatsis at users full stop sourceforge full stop net
  8 + *
  9 + * This script emulates Internet Explorer's selectNodes and selectSingleNode
  10 + * for Mozilla. Associating namespace prefixes with URIs for your XPath queries
  11 + * is easy with IE's setProperty.
  12 + * USers may also map a namespace prefix to a default (unprefixed) namespace in the
  13 + * source document with Sarissa.setXpathNamespaces
  14 + *
  15 + * ====================================================================
  16 + * Licence
  17 + * ====================================================================
  18 + * Sarissa is free software distributed under the GNU GPL version 2 (see <a href="gpl.txt">gpl.txt</a>) or higher,
  19 + * GNU LGPL version 2.1 (see <a href="lgpl.txt">lgpl.txt</a>) or higher and Apache Software License 2.0 or higher
  20 + * (see <a href="asl.txt">asl.txt</a>). This means you can choose one of the three and use that if you like. If
  21 + * you make modifications under the ASL, i would appreciate it if you submitted those.
  22 + * In case your copy of Sarissa does not include the license texts, you may find
  23 + * them online in various formats at <a href="http://www.gnu.org">http://www.gnu.org</a> and
  24 + * <a href="http://www.apache.org">http://www.apache.org</a>.
  25 + *
  26 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  27 + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  28 + * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
  29 + * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  30 + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  31 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  32 + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  33 + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  34 + */
  35 +if(Sarissa._SARISSA_HAS_DOM_FEATURE && document.implementation.hasFeature("XPath", "3.0")){
  36 + /**
  37 + * <p>SarissaNodeList behaves as a NodeList but is only used as a result to <code>selectNodes</code>,
  38 + * so it also has some properties IEs proprietery object features.</p>
  39 + * @private
  40 + * @constructor
  41 + * @argument i the (initial) list size
  42 + */
  43 + SarissaNodeList = function (i){
  44 + this.length = i;
  45 + };
  46 + /**
  47 + * <p>Set an Array as the prototype object</p>
  48 + * @private
  49 + */
  50 + SarissaNodeList.prototype = [];
  51 + /**
  52 + * <p>Inherit the Array constructor </p>
  53 + * @private
  54 + */
  55 + SarissaNodeList.prototype.constructor = Array;
  56 + /**
  57 + * <p>Returns the node at the specified index or null if the given index
  58 + * is greater than the list size or less than zero </p>
  59 + * <p><b>Note</b> that in ECMAScript you can also use the square-bracket
  60 + * array notation instead of calling <code>item</code>
  61 + * @argument i the index of the member to return
  62 + * @returns the member corresponding to the given index
  63 + * @private
  64 + */
  65 + SarissaNodeList.prototype.item = function(i) {
  66 + return (i < 0 || i >= this.length)?null:this[i];
  67 + };
  68 + /**
  69 + * <p>Emulate IE's expr property
  70 + * (Here the SarissaNodeList object is given as the result of selectNodes).</p>
  71 + * @returns the XPath expression passed to selectNodes that resulted in
  72 + * this SarissaNodeList
  73 + * @private
  74 + */
  75 + SarissaNodeList.prototype.expr = "";
  76 + /** dummy, used to accept IE's stuff without throwing errors */
  77 + if(window.XMLDocument && (!XMLDocument.prototype.setProperty)){
  78 + XMLDocument.prototype.setProperty = function(x,y){};
  79 + }
  80 + /**
  81 + * <p>Programmatically control namespace URI/prefix mappings for XPath
  82 + * queries.</p>
  83 + * <p>This method comes especially handy when used to apply XPath queries
  84 + * on XML documents with a default namespace, as there is no other way
  85 + * of mapping that to a prefix.</p>
  86 + * <p>Using no namespace prefix in DOM Level 3 XPath queries, implies you
  87 + * are looking for elements in the null namespace. If you need to look
  88 + * for nodes in the default namespace, you need to map a prefix to it
  89 + * first like:</p>
  90 + * <pre>Sarissa.setXpathNamespaces(oDoc, "xmlns:myprefix'http://mynsURI'");</pre>
  91 + * <p><b>Note 1 </b>: Use this method only if the source document features
  92 + * a default namespace (without a prefix), otherwise just use IE's setProperty
  93 + * (moz will rezolve non-default namespaces by itself). You will need to map that
  94 + * namespace to a prefix for queries to work.</p>
  95 + * <p><b>Note 2 </b>: This method calls IE's setProperty method to set the
  96 + * appropriate namespace-prefix mappings, so you dont have to do that.</p>
  97 + * @param oDoc The target XMLDocument to set the namespace mappings for.
  98 + * @param sNsSet A whilespace-seperated list of namespace declarations as
  99 + * those would appear in an XML document. E.g.:
  100 + * <code>&quot;xmlns:xhtml=&apos;http://www.w3.org/1999/xhtml&apos;
  101 + * xmlns:&apos;http://www.w3.org/1999/XSL/Transform&apos;&quot;</code>
  102 + * @throws An error if the format of the given namespace declarations is bad.
  103 + */
  104 + Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
  105 + //oDoc._sarissa_setXpathNamespaces(sNsSet);
  106 + oDoc._sarissa_useCustomResolver = true;
  107 + var namespaces = sNsSet.indexOf(" ")>-1?sNsSet.split(" "):[sNsSet];
  108 + oDoc._sarissa_xpathNamespaces = [];
  109 + for(var i=0;i < namespaces.length;i++){
  110 + var ns = namespaces[i];
  111 + var colonPos = ns.indexOf(":");
  112 + var assignPos = ns.indexOf("=");
  113 + if(colonPos > 0 && assignPos > colonPos+1){
  114 + var prefix = ns.substring(colonPos+1, assignPos);
  115 + var uri = ns.substring(assignPos+2, ns.length-1);
  116 + oDoc._sarissa_xpathNamespaces[prefix] = uri;
  117 + }else{
  118 + throw "Bad format on namespace declaration(s) given";
  119 + }
  120 + }
  121 + };
  122 + /**
  123 + * @private Flag to control whether a custom namespace resolver should
  124 + * be used, set to true by Sarissa.setXpathNamespaces
  125 + */
  126 + XMLDocument.prototype._sarissa_useCustomResolver = false;
  127 + /** @private */
  128 + XMLDocument.prototype._sarissa_xpathNamespaces = [];
  129 + /**
  130 + * <p>Extends the XMLDocument to emulate IE's selectNodes.</p>
  131 + * @argument sExpr the XPath expression to use
  132 + * @argument contextNode this is for internal use only by the same
  133 + * method when called on Elements
  134 + * @returns the result of the XPath search as a SarissaNodeList
  135 + * @throws An error if no namespace URI is found for the given prefix.
  136 + */
  137 + XMLDocument.prototype.selectNodes = function(sExpr, contextNode, returnSingle){
  138 + var nsDoc = this;
  139 + var nsresolver;
  140 + if(this._sarissa_useCustomResolver){
  141 + nsresolver = function(prefix){
  142 + var s = nsDoc._sarissa_xpathNamespaces[prefix];
  143 + if(s){
  144 + return s;
  145 + }
  146 + else {
  147 + throw "No namespace URI found for prefix: '" + prefix+"'";
  148 + }
  149 + };
  150 + }
  151 + else{
  152 + nsresolver = this.createNSResolver(this.documentElement);
  153 + }
  154 + var result = null;
  155 + if(!returnSingle){
  156 + var oResult = this.evaluate(sExpr,
  157 + (contextNode?contextNode:this),
  158 + nsresolver,
  159 + XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  160 + var nodeList = new SarissaNodeList(oResult.snapshotLength);
  161 + nodeList.expr = sExpr;
  162 + for(var i=0;i<nodeList.length;i++){
  163 + nodeList[i] = oResult.snapshotItem(i);
  164 + }
  165 + result = nodeList;
  166 + }
  167 + else {
  168 + result = this.evaluate(sExpr,
  169 + (contextNode?contextNode:this),
  170 + nsresolver,
  171 + XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  172 + }
  173 + return result;
  174 + };
  175 + /**
  176 + * <p>Extends the Element to emulate IE's selectNodes</p>
  177 + * @argument sExpr the XPath expression to use
  178 + * @returns the result of the XPath search as an (Sarissa)NodeList
  179 + * @throws An
  180 + * error if invoked on an HTML Element as this is only be
  181 + * available to XML Elements.
  182 + */
  183 + Element.prototype.selectNodes = function(sExpr){
  184 + var doc = this.ownerDocument;
  185 + if(doc.selectNodes){
  186 + return doc.selectNodes(sExpr, this);
  187 + }
  188 + else{
  189 + throw "Method selectNodes is only supported by XML Elements";
  190 + }
  191 + };
  192 + /**
  193 + * <p>Extends the XMLDocument to emulate IE's selectSingleNode.</p>
  194 + * @argument sExpr the XPath expression to use
  195 + * @argument contextNode this is for internal use only by the same
  196 + * method when called on Elements
  197 + * @returns the result of the XPath search as an (Sarissa)NodeList
  198 + */
  199 + XMLDocument.prototype.selectSingleNode = function(sExpr, contextNode){
  200 + var ctx = contextNode?contextNode:null;
  201 + return this.selectNodes(sExpr, ctx, true);
  202 + };
  203 + /**
  204 + * <p>Extends the Element to emulate IE's selectSingleNode.</p>
  205 + * @argument sExpr the XPath expression to use
  206 + * @returns the result of the XPath search as an (Sarissa)NodeList
  207 + * @throws An error if invoked on an HTML Element as this is only be
  208 + * available to XML Elements.
  209 + */
  210 + Element.prototype.selectSingleNode = function(sExpr){
  211 + var doc = this.ownerDocument;
  212 + if(doc.selectSingleNode){
  213 + return doc.selectSingleNode(sExpr, this);
  214 + }
  215 + else{
  216 + throw "Method selectNodes is only supported by XML Elements";
  217 + }
  218 + };
  219 + Sarissa.IS_ENABLED_SELECT_NODES = true;
  220 +}
0 221 \ No newline at end of file
... ...
pacotes/cswclient/lib/xml/csw-hosts.xml 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +<select name="cswhosts">
  2 + <option value="http://geomatics.nlr.nl/excat/csw">eXcat@nlr</option>
  3 + <option value="http://dinolks03.nitg.tno.nl/excat/csw">eXcat@tno</option>
  4 + <option value="http://www.geodata.alterra.nl/excat/csw">eXcat@alterra</option>
  5 + <option value="http://geonovum.nitg.tno.nl:8080/geonetwork/srv/en/csw">Geonovum</option>
  6 + <option value="http://www.metadados.inde.gov.br/geonetwork/srv/br/csw">INDE-BR</option>
  7 + <option value="http://mapas.mma.gov.br/geonetwork/srv/br/csw">INDE-MMA</option>
  8 +</select>
... ...
pacotes/cswclient/lib/xml/cswclient.xml 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +<div id="cswclient" class="clearfix" style="padding: 0 1em 4px 1em">
  2 +
  3 + <div id="query-container">
  4 + <div class="csw-main">
  5 + <div class="csw-content">
  6 + <div class="captioneddiv">
  7 + <h3>Simple CSW Client</h3>
  8 + <form name="theForm" method="POST" action="javascript:void(csw_client.getRecords())">
  9 + <select name="queryable">
  10 + <option value="anytext">AnyText</option>
  11 + <option value="title">Title</option>
  12 + <option value="subject">Subject</option>
  13 + </select>
  14 + <select name="operator">
  15 + <option value="contains">contains</option>
  16 + <option value="equals">equals</option>
  17 + </select>
  18 + <input type="text" name="query" value="" size="24"/>
  19 + <p/>
  20 + <span id="csw-hosts"></span>
  21 + <select id="schema" name="schema">
  22 + <option value="http://www.opengis.net/cat/csw/2.0.2">csw:Record</option>
  23 + <option value="http://www.isotc211.org/2005/gmd">ISO19139</option>
  24 + </select>
  25 + <select id="dislaymode" name="displaymode">
  26 + <option value="html">HTML</option>
  27 + <option value="xml">XML</option>
  28 + </select>
  29 + <select id="sortby" name="sortby">
  30 + <option value="none">No Sort</option>
  31 + <option value="title">Title</option>
  32 + </select>
  33 + <p/>
  34 + <!--input type="hidden" name="schema" value="http://www.opengis.net/cat/csw/2.0.2"/-->
  35 + <!--input type="hidden" name="schema" value="http://www.isotc211.org/2005/gmd"/-->
  36 + <!--input type="hidden" name="displaymode" value="html"/-->
  37 + <input type="button" value="clear" onClick="javascript:void(csw_client.clearPage())"/>
  38 + <input type="button" value="submit" onClick="javascript:void(csw_client.getRecords())"/>
  39 + </form>
  40 + </div>
  41 +
  42 + <div id="results-container">
  43 + <div class="csw-main2" id="results">
  44 + <div class="csw-contents">
  45 + <div id="csw-output"></div>
  46 + </div>
  47 + </div>
  48 + </div>
  49 +
  50 + </div>
  51 + </div><!-- main -->
  52 + </div><!-- query-container -->
  53 + <p/>
  54 + <div id="popup">
  55 + <div class="close">
  56 + <a href="javascript:void(csw_client.hideDiv(document.getElementById('popup')))">[close]</a>
  57 + </div>
  58 + <div id="popup2">
  59 + <div class="csw-content2">
  60 + <div id="metadata"></div>
  61 + </div>
  62 + </div>
  63 + </div><!-- popup -->
  64 + <div id="overlay" style="visibility:hidden"></div>
  65 + </div><!-- cswclient -->
... ...
pacotes/cswclient/lib/xml/defaults.xml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<defaults>
  2 +<version>2.0.2</version>
  3 +<maxrecords>10</maxrecords>
  4 +<startposition>1</startposition>
  5 +<outputformat>application/xml</outputformat>
  6 +<outputschema>http://www.opengis.net/cat/csw/2.0.2</outputschema>
  7 +<!--outputschema>http://www.isotc211.org/2005/gmd</outputschema-->
  8 +<resulttype>results</resulttype>
  9 +<propertyname>AnyText</propertyname>
  10 +<literal></literal>
  11 +<sortby></sortby>
  12 +<sortorder>ASC</sortorder>
  13 +<id></id>
  14 +</defaults>
... ...
pacotes/cswclient/lib/xsl/csw-metadata.xsl 0 → 100644
... ... @@ -0,0 +1,448 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  3 + xmlns:gco="http://www.isotc211.org/2005/gco"
  4 + xmlns:gmd="http://www.isotc211.org/2005/gmd"
  5 + xmlns:dc="http://purl.org/dc/elements/1.1/"
  6 + xmlns:dct="http://purl.org/dc/terms/"
  7 + xmlns:ows="http://www.opengis.net/ows"
  8 + xmlns:cat="http://www.esri.com/metadata/csw/">
  9 +
  10 +<xsl:output method="xml" encoding="ISO-8859-1"/>
  11 +
  12 +
  13 +<xsl:template match="/">
  14 + <div>
  15 + <xsl:apply-templates/>
  16 + </div>
  17 +</xsl:template>
  18 +
  19 +<xsl:template match="/*[local-name()='GetRecordByIdResponse']">
  20 + <xsl:apply-templates select="cat:FullRecord"/>
  21 + <xsl:apply-templates select="*[local-name()='Record']"/>
  22 + <xsl:apply-templates select="*[local-name()='SummaryRecord']"/>
  23 + <xsl:apply-templates select="*[local-name()='BriefRecord']"/>
  24 + <xsl:apply-templates select="gmd:MD_Metadata"/>
  25 + <xsl:apply-templates select="Metadata"/>
  26 + <xsl:apply-templates select="metadata"/>
  27 +</xsl:template>
  28 +
  29 +<xsl:template match="cat:FullRecord">
  30 + <xsl:apply-templates select="metadata"/>
  31 +</xsl:template>
  32 +
  33 +
  34 +<!-- Start Metadata ISO19139 -->
  35 +<xsl:template match="gmd:MD_Metadata">
  36 + <!-- First the Identification block -->
  37 + <xsl:apply-templates select="./gmd:identificationInfo/gmd:MD_DataIdentification"/>
  38 + <xsl:apply-templates select="./gmd:distributionInfo/gmd:MD_Distribution"/>
  39 +
  40 +<!-- Metadata block -->
  41 +<div class="captioneddiv">
  42 +<h3>Metadata</h3>
  43 +<table class="meta"><tr></tr>
  44 + <xsl:call-template name="tablerow">
  45 + <xsl:with-param name="cname" select="'File Identifier'"/>
  46 + <xsl:with-param name="cvalue" select="./gmd:fileIdentifier/gco:CharacterString"/>
  47 + </xsl:call-template>
  48 + <xsl:call-template name="tablerow">
  49 + <xsl:with-param name="cname" select="'Language'"/>
  50 + <xsl:with-param name="cvalue" select="./gmd:language/gco:CharacterString"/>
  51 + </xsl:call-template>
  52 + <xsl:call-template name="tablerow">
  53 + <xsl:with-param name="cname" select="'Character set'"/>
  54 + <xsl:with-param name="cvalue" select="./gmd:characterSet/gmd:MD_CharacterSetCode/@codeListValue"/>
  55 + </xsl:call-template>
  56 + <xsl:call-template name="tablerow">
  57 + <xsl:with-param name="cname" select="'Date stamp'"/>
  58 + <xsl:with-param name="cvalue" select="./gmd:dateStamp/gco:Date"/>
  59 + </xsl:call-template>
  60 + <xsl:call-template name="tablerow">
  61 + <xsl:with-param name="cname" select="'Metadata standard name'"/>
  62 + <xsl:with-param name="cvalue" select="./gmd:metadataStandardName/gco:CharacterString"/>
  63 + </xsl:call-template>
  64 + <xsl:call-template name="tablerow">
  65 + <xsl:with-param name="cname" select="'Metadata standard version'"/>
  66 + <xsl:with-param name="cvalue" select="./gmd:metadataStandardVersion/gco:CharacterString"/>
  67 + </xsl:call-template>
  68 +</table>
  69 + <xsl:apply-templates select="./gmd:contact"/>
  70 +</div>
  71 +</xsl:template>
  72 +
  73 +<!-- 'Metadata->Metadata author' block -->
  74 +<xsl:template match="gmd:contact">
  75 +<div class="captioneddiv">
  76 +<h3>Metadata author</h3>
  77 +<table class="meta">
  78 +<tr>
  79 +<td class="meta" valign="top">
  80 +<table class="meta"><tr></tr>
  81 + <xsl:call-template name="tablerow">
  82 + <xsl:with-param name="cname" select="'Individual name'"/>
  83 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:individualName/gco:CharacterString"/>
  84 + </xsl:call-template>
  85 + <xsl:call-template name="tablerow">
  86 + <xsl:with-param name="cname" select="'Organisation name'"/>
  87 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString"/>
  88 + </xsl:call-template>
  89 + <xsl:call-template name="tablerow">
  90 + <xsl:with-param name="cname" select="'Position'"/>
  91 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:positionName/gco:CharacterString"/>
  92 + </xsl:call-template>
  93 + <xsl:call-template name="tablerow">
  94 + <xsl:with-param name="cname" select="'Role'"/>
  95 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode/@codeListValue"/>
  96 + </xsl:call-template>
  97 +</table></td>
  98 +<td class="meta" valign="top">
  99 +<table class="meta"><tr></tr>
  100 + <xsl:call-template name="tablerow">
  101 + <xsl:with-param name="cname" select="'Voice'"/>
  102 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:phone/gmd:CI_Telephone/gmd:voice/gco:CharacterString"/>
  103 + </xsl:call-template>
  104 + <xsl:call-template name="tablerow">
  105 + <xsl:with-param name="cname" select="'Facsimile'"/>
  106 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:phone/gmd:CI_Telephone/gmd:facsimile/gco:CharacterString"/>
  107 + </xsl:call-template>
  108 + <xsl:call-template name="tablerow">
  109 + <xsl:with-param name="cname" select="'Delivery Point'"/>
  110 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:deliveryPoint/gco:CharacterString"/>
  111 + </xsl:call-template>
  112 + <xsl:call-template name="tablerow">
  113 + <xsl:with-param name="cname" select="'City'"/>
  114 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:city/gco:CharacterString"/>
  115 + </xsl:call-template>
  116 + <xsl:call-template name="tablerow">
  117 + <xsl:with-param name="cname" select="'Postal code'"/>
  118 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:postalCode/gco:CharacterString"/>
  119 + </xsl:call-template>
  120 + <xsl:call-template name="tablerow">
  121 + <xsl:with-param name="cname" select="'Country'"/>
  122 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:country/gco:CharacterString"/>
  123 + </xsl:call-template>
  124 + <xsl:call-template name="tablerow">
  125 + <xsl:with-param name="cname" select="'Email'"/>
  126 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString"/>
  127 + </xsl:call-template>
  128 +</table></td>
  129 +</tr>
  130 +</table>
  131 +</div>
  132 +</xsl:template>
  133 +
  134 +<!-- 'Identification' block -->
  135 +<xsl:template match="gmd:MD_DataIdentification">
  136 +<div class="captioneddiv">
  137 +<h3>Identification info</h3>
  138 +<table class="meta"><tr></tr>
  139 + <xsl:call-template name="tablerow">
  140 + <xsl:with-param name="cname" select="'Title'"/>
  141 + <xsl:with-param name="cvalue" select="./gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString"/>
  142 + </xsl:call-template>
  143 + <xsl:call-template name="tablerow">
  144 + <xsl:with-param name="cname" select="'Date'"/>
  145 + <xsl:with-param name="cvalue" select="./gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:data/gco:Date"/>
  146 + </xsl:call-template>
  147 + <!--xsl:call-template name="tablerow">
  148 + <xsl:with-param name="cname" select="'Presentation form'"/>
  149 + <xsl:with-param name="cvalue" select="./idCitation/presForm/PresFormCd/@value"/>
  150 + </xsl:call-template-->
  151 + <xsl:call-template name="tablerow">
  152 + <xsl:with-param name="cname" select="'Individual name'"/>
  153 + <xsl:with-param name="cvalue" select="./gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:individualName/gco:CharacterString"/>
  154 + </xsl:call-template>
  155 + <xsl:call-template name="tablerow">
  156 + <xsl:with-param name="cname" select="'Organisation name'"/>
  157 + <xsl:with-param name="cvalue" select="./gmd:pointOfContact/gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString"/>
  158 + </xsl:call-template>
  159 +
  160 + <!--abstract is handled seperately because of text formatting-->
  161 + <tr>
  162 + <td class="meta-param">Abstract:</td>
  163 + <td class="meta-value">
  164 + <xsl:apply-templates select="./gmd:abstract"/>
  165 + </td>
  166 + </tr>
  167 +</table>
  168 + <xsl:apply-templates select="./gmd:extent"/>
  169 + <xsl:apply-templates select="./gmd:pointOfContact"/>
  170 +</div>
  171 +</xsl:template>
  172 +
  173 +<!-- 'Identification->Point of Contact' block -->
  174 +<xsl:template match="gmd:pointOfContact">
  175 +<div class="captioneddiv">
  176 +<h3>Point of Contact</h3>
  177 +<table class="meta">
  178 +<tr>
  179 +<td class="meta" valign="top">
  180 +<table class="meta"><tr></tr>
  181 + <xsl:call-template name="tablerow">
  182 + <xsl:with-param name="cname" select="'Individual name'"/>
  183 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:individualName/gco:CharacterString"/>
  184 + </xsl:call-template>
  185 + <xsl:call-template name="tablerow">
  186 + <xsl:with-param name="cname" select="'Organisation name'"/>
  187 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:organisationName/gco:CharacterString"/>
  188 + </xsl:call-template>
  189 + <xsl:call-template name="tablerow">
  190 + <xsl:with-param name="cname" select="'Position'"/>
  191 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:positionName/gco:CharacterString"/>
  192 + </xsl:call-template>
  193 + <xsl:call-template name="tablerow">
  194 + <xsl:with-param name="cname" select="'Role'"/>
  195 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:role/gmd:CI_RoleCode/@codeListValue"/>
  196 + </xsl:call-template>
  197 +</table></td>
  198 +<td class="meta" valign="top">
  199 +<table class="meta"><tr></tr>
  200 + <xsl:call-template name="tablerow">
  201 + <xsl:with-param name="cname" select="'Voice'"/>
  202 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:phone/gmd:CI_Telephone/gmd:voice/gco:CharacterString"/>
  203 + </xsl:call-template>
  204 + <xsl:call-template name="tablerow">
  205 + <xsl:with-param name="cname" select="'Facsimile'"/>
  206 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:phone/gmd:CI_Telephone/gmd:facsimile/gco:CharacterString"/>
  207 + </xsl:call-template>
  208 + <xsl:call-template name="tablerow">
  209 + <xsl:with-param name="cname" select="'Delivery Point'"/>
  210 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:deliveryPoint/gco:CharacterString"/>
  211 + </xsl:call-template>
  212 + <xsl:call-template name="tablerow">
  213 + <xsl:with-param name="cname" select="'City'"/>
  214 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:city/gco:CharacterString"/>
  215 + </xsl:call-template>
  216 + <xsl:call-template name="tablerow">
  217 + <xsl:with-param name="cname" select="'Postal code'"/>
  218 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:postalCode/gco:CharacterString"/>
  219 + </xsl:call-template>
  220 + <xsl:call-template name="tablerow">
  221 + <xsl:with-param name="cname" select="'Country'"/>
  222 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:country/gco:CharacterString"/>
  223 + </xsl:call-template>
  224 + <xsl:call-template name="tablerow">
  225 + <xsl:with-param name="cname" select="'Email'"/>
  226 + <xsl:with-param name="cvalue" select="./gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString"/>
  227 + </xsl:call-template>
  228 +</table></td>
  229 +</tr>
  230 +</table>
  231 +</div>
  232 +</xsl:template>
  233 +
  234 +<!-- 'Identification->Geographic box' block -->
  235 +<xsl:template match="gmd:extent">
  236 +<xsl:if test="./gmd:EX_Extent/gmd:geographicElement">
  237 +<div class="captioneddiv">
  238 +<h3>Geographic box</h3>
  239 +<br/>
  240 +<table class="meta" width="100%" align="center"><tr></tr>
  241 +<tr>
  242 +<td></td><td class="meta-param" align="center">North bound latitude<br/>
  243 +<font color="#000000"><xsl:value-of select="./gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:northBoundLatitude/gco:Decimal"/></font></td><td></td>
  244 +</tr>
  245 +<tr>
  246 +<td class="meta-param" align="center">West bound longitude<br/>
  247 +<font color="#000000"><xsl:value-of select="./gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:westBoundLongitude/gco:Decimal"/></font></td>
  248 +<td></td>
  249 +<td class="meta-param" align="center">East bound longitude<br/>
  250 +<font color="#000000"><xsl:value-of select="./gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:eastBoundLongitude/gco:Decimal"/></font></td>
  251 +</tr>
  252 +<tr>
  253 +<td></td><td class="meta-param" align="center">South bound latitude<br/>
  254 +<font color="#000000"><xsl:value-of select="./gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox/gmd:southBoundLatitude/gco:Decimal"/></font></td><td></td>
  255 +</tr>
  256 +</table>
  257 +</div>
  258 +</xsl:if>
  259 +</xsl:template>
  260 +
  261 +<!-- 'Distribution Info' block -->
  262 +<xsl:template match="gmd:MD_Distribution">
  263 +<div class="captioneddiv">
  264 +<h3>Distribution info</h3>
  265 +<table class="meta"><tr></tr>
  266 + <xsl:for-each select="gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource">
  267 + <xsl:choose>
  268 + <xsl:when test="starts-with(./gmd:protocol/gco:CharacterString,'WWW:DOWNLOAD-') and contains(./gmd:protocol/gco:CharacterString,'http--download') and ./gmd:name/gco:CharacterString">
  269 + <tr>
  270 + <td class="meta-param">Download:</td>
  271 + <td class="meta-value">
  272 + <a><xsl:attribute name="href">
  273 + <xsl:value-of select="gmd:linkage/gmd:URL"/>
  274 + </xsl:attribute>
  275 + <xsl:value-of select="gmd:name/gco:CharacterString"/>
  276 + </a>
  277 + </td>
  278 + </tr>
  279 + </xsl:when>
  280 + <xsl:when test="starts-with(./gmd:protocol/gco:CharacterString,'ESRI:AIMS-') and contains(./gmd:protocol/gco:CharacterString,'-get-image') and ./gmd:name/gco:CharacterString">
  281 + <tr>
  282 + <td class="meta-param">Esri ArcIms:</td>
  283 + <td class="meta-value">
  284 + <a><xsl:attribute name="href">
  285 + <xsl:value-of select="gmd:linkage/gmd:URL"/>
  286 + </xsl:attribute>
  287 + <xsl:value-of select="gmd:name/gco:CharacterString"/>
  288 + </a>
  289 + </td>
  290 + </tr>
  291 + </xsl:when>
  292 + <xsl:when test="starts-with(./gmd:protocol/gco:CharacterString,'OGC:WMS-') and contains(./gmd:protocol/gco:CharacterString,'-get-map') and ./gmd:name/gco:CharacterString">
  293 + <tr>
  294 + <td class="meta-param">OGC-WMS:</td>
  295 + <td class="meta-value">
  296 + <a><xsl:attribute name="href">
  297 + <xsl:text>javascript:void(window.open('</xsl:text>
  298 + <xsl:value-of select="gmd:linkage/gmd:URL"/>
  299 + <xsl:text>'))</xsl:text>
  300 + </xsl:attribute>
  301 + <xsl:value-of select="gmd:name/gco:CharacterString"/>
  302 + </a>
  303 + </td>
  304 + </tr>
  305 + </xsl:when>
  306 + <xsl:when test="starts-with(./gmd:protocol/gco:CharacterString,'OGC:WMS-') and contains(./gmd:protocol/gco:CharacterString,'-get-capabilities') and ./gmd:name/gco:CharacterString">
  307 + <tr>
  308 + <td class="meta-param">OGC-WMS Capabilities:</td>
  309 + <td class="meta-value">
  310 + <a><xsl:attribute name="href">
  311 + <xsl:value-of select="gmd:linkage/gmd:URL"/>
  312 + </xsl:attribute>
  313 + <xsl:value-of select="gmd:name/gco:CharacterString"/>
  314 + </a>
  315 + </td>
  316 + </tr>
  317 + </xsl:when>
  318 + <!--xsl:when test="linkage[text()]">
  319 + <link type="url"><xsl:value-of select="linkage[text()]"/></link>
  320 + </xsl:when-->
  321 + </xsl:choose>
  322 + </xsl:for-each>
  323 +</table>
  324 +</div>
  325 +</xsl:template>
  326 +
  327 +<!-- 'Identification->Abstract -->
  328 +<xsl:template match="gmd:abstract">
  329 +<xsl:apply-templates select="./gco:CharacterString/text()"/>
  330 +</xsl:template>
  331 +<!-- End Metadata ISO19139 -->
  332 +
  333 +
  334 +<!-- StartMetadata Dublin Core -->
  335 +
  336 +<!-- 'Identification' block -->
  337 +<xsl:template match="*[local-name()='Record']|*[local-name()='SummaryRecord']|*[local-name()='BriefRecord']">
  338 +<div class="captioneddiv">
  339 +<h3>Identification info</h3>
  340 +<table class="meta"><tr></tr>
  341 + <xsl:call-template name="tablerow">
  342 + <xsl:with-param name="cname" select="'Title'"/>
  343 + <xsl:with-param name="cvalue" select="./dc:title"/>
  344 + </xsl:call-template>
  345 + <xsl:call-template name="tablerow">
  346 + <xsl:with-param name="cname" select="'Date'"/>
  347 + <xsl:with-param name="cvalue" select="./dc:date"/>
  348 + </xsl:call-template>
  349 + <xsl:call-template name="tablerow">
  350 + <xsl:with-param name="cname" select="'Presentation form'"/>
  351 + <xsl:with-param name="cvalue" select="./dc:format"/>
  352 + </xsl:call-template>
  353 + <xsl:call-template name="tablerow">
  354 + <xsl:with-param name="cname" select="'Individual name'"/>
  355 + <xsl:with-param name="cvalue" select="./dc:publisher"/>
  356 + </xsl:call-template>
  357 + <xsl:call-template name="tablerow">
  358 + <xsl:with-param name="cname" select="'Identifier'"/>
  359 + <xsl:with-param name="cvalue" select="./dc:identifier"/>
  360 + </xsl:call-template>
  361 +<xsl:if test="./dct:abstract">
  362 +<tr><!-- this "tr" causes problems for new line replacement by "p" -->
  363 +<td class="meta-param">Abstract:</td><td class="meta-value"><xsl:apply-templates select="./dct:abstract"/></td>
  364 +</tr>
  365 +</xsl:if>
  366 + <xsl:for-each select="./dc:subject">
  367 + <xsl:call-template name="tablerow">
  368 + <xsl:with-param name="cname" select="'Keyword'"/>
  369 + <xsl:with-param name="cvalue" select="."/>
  370 + </xsl:call-template>
  371 + </xsl:for-each>
  372 +</table>
  373 +<xsl:apply-templates select="./ows:BoundingBox"/>
  374 +<xsl:apply-templates select="./ows:WGS84BoundingBox"/>
  375 +</div>
  376 +</xsl:template>
  377 +
  378 +
  379 +<xsl:template match="dct:abstract">
  380 +<!--xsl:value-of select="."/-->
  381 +<xsl:apply-templates select="text()"/>
  382 +</xsl:template>
  383 +
  384 +<!-- 'Identification->Geographic box' block -->
  385 +<xsl:template match="ows:BoundingBox|ows:WGS84BoundingBox">
  386 +<div class="captioneddiv">
  387 +<h3>Geographic box</h3>
  388 +<table class="meta"><tr></tr>
  389 + <xsl:call-template name="tablerow">
  390 + <xsl:with-param name="cname" select="'Lower corner'"/>
  391 + <xsl:with-param name="cvalue" select="./ows:LowerCorner"/>
  392 + </xsl:call-template>
  393 + <xsl:call-template name="tablerow">
  394 + <xsl:with-param name="cname" select="'Upper corner'"/>
  395 + <xsl:with-param name="cvalue" select="./ows:UpperCorner"/>
  396 + </xsl:call-template>
  397 +</table>
  398 +</div>
  399 +</xsl:template>
  400 +<!-- End Metadata Dublin Core -->
  401 +
  402 +<!-- Start Utills -->
  403 +<xsl:template match="text()">
  404 + <xsl:call-template name="to-para">
  405 + <xsl:with-param name="from" select="'&#10;&#10;'"/>
  406 + <xsl:with-param name="string" select="."/>
  407 + </xsl:call-template>
  408 +</xsl:template>
  409 +
  410 +<!-- replace all occurences of the character(s) `from'
  411 + by <p/> in the string `string'.-->
  412 +<xsl:template name="to-para" >
  413 + <xsl:param name="string"/>
  414 + <xsl:param name="from"/>
  415 + <xsl:choose>
  416 + <xsl:when test="contains($string,$from)">
  417 + <xsl:value-of select="substring-before($string,$from)"/>
  418 + <!-- output a <p/> tag instead of `from' -->
  419 + <p/>
  420 + <xsl:call-template name="to-para">
  421 + <xsl:with-param name="string" select="substring-after($string,$from)"/>
  422 + <xsl:with-param name="from" select="$from"/>
  423 + </xsl:call-template>
  424 + </xsl:when>
  425 + <xsl:otherwise>
  426 + <xsl:value-of select="$string"/>
  427 + </xsl:otherwise>
  428 + </xsl:choose>
  429 +</xsl:template>
  430 +
  431 +
  432 +<xsl:template name="tablerow" >
  433 + <xsl:param name="cname"/>
  434 + <xsl:param name="cvalue"/>
  435 + <xsl:choose>
  436 + <xsl:when test="string($cvalue)">
  437 + <tr>
  438 + <td class="meta-param"><xsl:value-of select="$cname"/><xsl:text>: </xsl:text></td>
  439 + <td class="meta-value"><xsl:value-of select="$cvalue"/></td>
  440 + </tr>
  441 + </xsl:when>
  442 + <xsl:otherwise>
  443 + </xsl:otherwise>
  444 + </xsl:choose>
  445 +</xsl:template>
  446 +<!-- End Utills -->
  447 +
  448 +</xsl:stylesheet>
... ...
pacotes/cswclient/lib/xsl/csw-results.xsl 0 → 100644
... ... @@ -0,0 +1,146 @@
  1 +<?xml version="1.0"?>
  2 +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  3 + xmlns:dc="http://purl.org/dc/elements/1.1/"
  4 + xmlns:dct="http://purl.org/dc/terms/">
  5 +<!--xsl:output method="html" encoding="ISO-8859-1"/-->
  6 +
  7 +
  8 +<xsl:variable name="pageUrl">
  9 + <xsl:text>javascript:(csw_client.getRecords</xsl:text>
  10 + <xsl:text>('</xsl:text>
  11 +</xsl:variable>
  12 +
  13 +
  14 +<xsl:template match="/results/*[local-name()='GetRecordsResponse']">
  15 + <xsl:apply-templates select="./*[local-name()='SearchResults']"/>
  16 +</xsl:template>
  17 +
  18 +
  19 +<xsl:template match="*[local-name()='SearchResults']">
  20 +
  21 +
  22 +<xsl:variable name="start">
  23 + <xsl:value-of select="../../request/@start"/>
  24 +</xsl:variable>
  25 +
  26 +<!-- because GeoNetwork does not return nextRecord we have to do some calculation -->
  27 +<xsl:variable name="next">
  28 + <xsl:choose>
  29 + <xsl:when test="@nextRecord">
  30 + <xsl:value-of select="@nextRecord"/>
  31 + </xsl:when>
  32 + <xsl:otherwise>
  33 + <xsl:choose>
  34 + <xsl:when test="number(@numberOfRecordsMatched) >= (number($start) + number(@numberOfRecordsReturned))">
  35 + <xsl:value-of select="number($start) + number(@numberOfRecordsReturned)"/>
  36 + </xsl:when>
  37 + <xsl:otherwise>
  38 + <xsl:value-of select="0"/>
  39 + </xsl:otherwise>
  40 + </xsl:choose>
  41 + </xsl:otherwise>
  42 + </xsl:choose>
  43 +</xsl:variable>
  44 +
  45 +<div class="captioneddiv">
  46 +
  47 +<!--xsl:if test="number(@numberOfRecordsMatched) > number(@numberOfRecordsReturned)"-->
  48 +<!-- because ESRI GPT returns always numberOfRecordsMatched = 0 -->
  49 +<xsl:if test="number(@numberOfRecordsReturned) > 0 and ($start > 1 or number($next) > 0)">
  50 + <h3 style="float:right;top: -2.5em;">
  51 + <xsl:if test="$start > 1">
  52 + <a>
  53 + <xsl:attribute name="href">
  54 + <xsl:value-of select="$pageUrl"/>
  55 + <xsl:value-of select="number($start)-number(../../request/@maxrecords)"/>
  56 + <xsl:text>'))</xsl:text>
  57 + </xsl:attribute>
  58 + <xsl:text>&lt;&lt; previous</xsl:text>
  59 + </a>
  60 + </xsl:if>
  61 + <xsl:text> || </xsl:text>
  62 + <xsl:if test="number($next) > 0">
  63 + <a>
  64 + <xsl:attribute name="href">
  65 + <xsl:value-of select="$pageUrl"/>
  66 + <xsl:value-of select="$next"/>
  67 + <xsl:text>'))</xsl:text>
  68 + </xsl:attribute>
  69 + <xsl:text>next &gt;&gt;</xsl:text>
  70 + </a>
  71 + </xsl:if>
  72 + </h3>
  73 +</xsl:if>
  74 +
  75 +<h3>Total records returned: <xsl:value-of select="@numberOfRecordsReturned"/>
  76 +(of <xsl:value-of select="@numberOfRecordsMatched"/>)
  77 +</h3>
  78 +
  79 +<br/>
  80 + <ol>
  81 + <xsl:attribute name="start">
  82 + <xsl:value-of select="$start"/>
  83 + </xsl:attribute>
  84 + <xsl:for-each select="./*[local-name()='SummaryRecord']|./*[local-name()='BriefRecord']|./*[local-name()='Record']">
  85 + <li>
  86 + <strong><xsl:text>Title: </xsl:text></strong>
  87 + <a>
  88 + <xsl:attribute name="href">
  89 + <xsl:text>javascript:(csw_client.getRecordById</xsl:text>
  90 + <xsl:text>('</xsl:text>
  91 + <xsl:value-of select="./dc:identifier"/>
  92 + <xsl:text>'))</xsl:text>
  93 + </xsl:attribute>
  94 + <xsl:choose>
  95 + <xsl:when test="./dc:title">
  96 + <xsl:apply-templates select="./dc:title"/>
  97 + </xsl:when>
  98 + <xsl:otherwise>
  99 + <xsl:text> ...</xsl:text>
  100 + </xsl:otherwise>
  101 + </xsl:choose>
  102 + </a>
  103 + <br/>
  104 + <xsl:apply-templates select="./dct:abstract"/>
  105 + <br/>
  106 + <strong><xsl:text>Keywords: </xsl:text></strong>
  107 + <xsl:for-each select="./dc:subject">
  108 + <xsl:if test=".!=''">
  109 + <xsl:if test="position() &gt; 1">, </xsl:if>
  110 + <i><xsl:value-of select="."/></i>
  111 + </xsl:if>
  112 + </xsl:for-each>
  113 + <hr/>
  114 + </li>
  115 + </xsl:for-each>
  116 + </ol>
  117 +</div>
  118 +</xsl:template>
  119 +
  120 +<xsl:template match="dc:title">
  121 + <xsl:choose>
  122 + <xsl:when test=".!=''">
  123 + <xsl:value-of select="."/>
  124 + </xsl:when>
  125 + <xsl:otherwise>
  126 + <xsl:text> ...</xsl:text>
  127 + </xsl:otherwise>
  128 + </xsl:choose>
  129 +</xsl:template>
  130 +
  131 +<xsl:template match="dct:abstract">
  132 + <strong><xsl:text>Abstract: </xsl:text></strong>
  133 + <xsl:value-of select="substring(.,1,250)"/>
  134 + <xsl:text> ...</xsl:text>
  135 + <a>
  136 + <xsl:attribute name="href">
  137 + <xsl:text>javascript:(csw_client.getRecordById</xsl:text>
  138 + <xsl:text>('</xsl:text>
  139 + <xsl:value-of select="../dc:identifier"/>
  140 + <xsl:text>'))</xsl:text>
  141 + </xsl:attribute>
  142 + <xsl:text> more</xsl:text>
  143 + </a>
  144 +</xsl:template>
  145 +
  146 +</xsl:stylesheet>
... ...
pacotes/cswclient/lib/xsl/getrecordbyid.xsl 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<xsl:stylesheet version="1.0"
  3 + xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
  4 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5 + xmlns:xlink="http://www.w3.org/1999/xlink">
  6 +
  7 + <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
  8 + <xsl:strip-space elements="*"/>
  9 +
  10 + <!-- Match Root -->
  11 + <xsl:template match="/defaults">
  12 +
  13 + <csw:GetRecordById
  14 + xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
  15 + service = "CSW">
  16 + <xsl:attribute name="version">
  17 + <xsl:value-of select="./version"/>
  18 + </xsl:attribute>
  19 + <xsl:attribute name="outputFormat">
  20 + <xsl:value-of select="./outputformat"/>
  21 + </xsl:attribute>
  22 + <xsl:attribute name="outputSchema">
  23 + <xsl:value-of select="./outputschema"/>
  24 + </xsl:attribute>
  25 + <csw:Id>
  26 + <xsl:value-of select="./id"/>
  27 + </csw:Id>
  28 + <csw:ElementSetName>full</csw:ElementSetName>
  29 + </csw:GetRecordById>
  30 +
  31 + </xsl:template>
  32 +</xsl:stylesheet>
0 33 \ No newline at end of file
... ...
pacotes/cswclient/lib/xsl/getrecords.xsl 0 → 100644
... ... @@ -0,0 +1,71 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<xsl:stylesheet version="1.0"
  3 + xmlns:ogc="http://www.opengis.net/ogc"
  4 + xmlns:ows="http://www.opengis.net/ows"
  5 + xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
  6 + xmlns:gml="http://www.opengis.net/gml"
  7 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8 + xmlns:xlink="http://www.w3.org/1999/xlink">
  9 +
  10 + <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
  11 + <xsl:strip-space elements="*"/>
  12 +
  13 +
  14 + <!-- Match Root -->
  15 + <xsl:template match="/defaults">
  16 +
  17 + <csw:GetRecords
  18 + xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
  19 + service = "CSW">
  20 + <xsl:attribute name="version">
  21 + <xsl:value-of select="./version"/>
  22 + </xsl:attribute>
  23 + <xsl:attribute name="maxRecords">
  24 + <xsl:value-of select="./maxrecords"/>
  25 + </xsl:attribute>
  26 + <xsl:attribute name="startPosition">
  27 + <xsl:value-of select="./startposition"/>
  28 + </xsl:attribute>
  29 + <xsl:attribute name="outputFormat">
  30 + <xsl:value-of select="./outputformat"/>
  31 + </xsl:attribute>
  32 + <xsl:attribute name="outputSchema">
  33 + <xsl:value-of select="./outputschema"/>
  34 + </xsl:attribute>
  35 + <xsl:attribute name="resultType">
  36 + <xsl:value-of select="./resulttype"/>
  37 + </xsl:attribute>
  38 + <csw:Query typeNames="csw:Record">
  39 + <csw:ElementSetName>summary</csw:ElementSetName>
  40 + <!-- Don't add Constraint if searh term is empty; this keeps Geonetwork happy -->
  41 + <xsl:if test="./literal !=''">
  42 + <csw:Constraint version="1.1.0">
  43 + <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
  44 + <ogc:PropertyIsLike escape="\" singleChar="_" wildCard="%">
  45 + <ogc:PropertyName>
  46 + <xsl:value-of select="./propertyname"/>
  47 + </ogc:PropertyName>
  48 + <ogc:Literal>
  49 + <xsl:value-of select="./literal"/>
  50 + </ogc:Literal>
  51 + </ogc:PropertyIsLike>
  52 + </ogc:Filter>
  53 + </csw:Constraint>
  54 + </xsl:if>
  55 + <ogc:SortBy xmlns:ogc="http://www.opengis.net/ogc">
  56 + <xsl:if test="./sortby !=''">
  57 + <ogc:SortProperty>
  58 + <ogc:PropertyName>
  59 + <xsl:value-of select="./sortby"/>
  60 + </ogc:PropertyName>
  61 + <ogc:SortOrder>
  62 + <xsl:value-of select="./sortorder"/>
  63 + </ogc:SortOrder>
  64 + </ogc:SortProperty>
  65 + </xsl:if>
  66 + </ogc:SortBy>
  67 + </csw:Query>
  68 + </csw:GetRecords>
  69 +
  70 + </xsl:template>
  71 +</xsl:stylesheet>
0 72 \ No newline at end of file
... ...
pacotes/cswclient/lib/xsl/prettyxml.xsl 0 → 100644
... ... @@ -0,0 +1,134 @@
  1 +<?xml version="1.0"?>
  2 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3 +<!--xsl:output method="html" encoding="ISO-8859-1"/-->
  4 +
  5 + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  6 + <!-- XML formatting -->
  7 + <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  8 +
  9 + <!--
  10 + draws an element as xml document
  11 + -->
  12 + <xsl:template match="/">
  13 + <div class="captioneddiv">
  14 + <h3>XML presentation</h3>
  15 + <br/>
  16 + <xsl:apply-templates mode="showXMLElement" select="."/>
  17 + </div>
  18 + </xsl:template>
  19 +
  20 +
  21 + <!--
  22 + draws an element in xml
  23 + -->
  24 + <xsl:template mode="showXMLElement" match="*">
  25 + <xsl:choose>
  26 +
  27 + <!-- has children -->
  28 + <xsl:when test="*">
  29 + <xsl:call-template name="showXMLStartTag"/>
  30 + <dl>
  31 + <xsl:for-each select="*">
  32 + <dd>
  33 + <xsl:apply-templates select="." mode="showXMLElement"/>
  34 + </dd>
  35 + </xsl:for-each>
  36 + </dl>
  37 + <xsl:call-template name="showEndTag"/>
  38 + </xsl:when>
  39 +
  40 + <!-- no children but text -->
  41 + <xsl:when test="text()">
  42 + <xsl:call-template name="showXMLStartTag"/>
  43 + <xsl:value-of select="text()"/>
  44 + <xsl:call-template name="showEndTag"/>
  45 + </xsl:when>
  46 +
  47 + <!-- empty element -->
  48 + <xsl:otherwise>
  49 + <xsl:call-template name="showXMLStartEndTag"/>
  50 + </xsl:otherwise>
  51 + </xsl:choose>
  52 + </xsl:template>
  53 +
  54 + <!--
  55 + draws the start tag of an element
  56 + -->
  57 + <xsl:template name="showXMLStartTag">
  58 + <font color="#4444ff">
  59 + <xsl:text>&lt;</xsl:text>
  60 + <xsl:value-of select="name(.)"/>
  61 + <xsl:call-template name="showXMLNamespaces"/>
  62 + <xsl:call-template name="showXMLAttributes"/>
  63 + <xsl:text>&gt;</xsl:text>
  64 + </font>
  65 + </xsl:template>
  66 +
  67 + <!--
  68 + draws the end tag of an element
  69 + -->
  70 + <xsl:template name="showEndTag">
  71 + <font color="#4444ff">
  72 + <xsl:text>&lt;/</xsl:text>
  73 + <xsl:value-of select="name(.)"/>
  74 + <xsl:text>&gt;</xsl:text>
  75 + </font>
  76 + </xsl:template>
  77 +
  78 + <!--
  79 + draws the empty tag of an element
  80 + -->
  81 + <xsl:template name="showXMLStartEndTag">
  82 + <font color="#4444ff">
  83 + <xsl:text>&lt;</xsl:text>
  84 + <xsl:value-of select="name(.)"/>
  85 + </font>
  86 + <xsl:call-template name="showXMLNamespaces"/>
  87 + <xsl:call-template name="showXMLAttributes"/>
  88 + <font color="#4444ff">
  89 + <xsl:text>/&gt;</xsl:text>
  90 + </font>
  91 + </xsl:template>
  92 +
  93 + <!--
  94 + draws attributes of an element
  95 + -->
  96 + <xsl:template name="showXMLAttributes">
  97 + <xsl:for-each select="@*">
  98 + <xsl:text> </xsl:text>
  99 + <font color="#44aa44">
  100 + <xsl:value-of select="name(.)"/>
  101 + </font>
  102 + <xsl:text>=</xsl:text>
  103 + <font color="#ff4444">
  104 + <xsl:text>"</xsl:text>
  105 + <xsl:value-of select="string()"/>
  106 + <xsl:text>"</xsl:text>
  107 + </font>
  108 + </xsl:for-each>
  109 + </xsl:template>
  110 +
  111 + <!--
  112 + draws namespaces of an element
  113 + -->
  114 + <xsl:template name="showXMLNamespaces">
  115 + <xsl:variable name="parent" select=".."/>
  116 + <xsl:for-each select="namespace::*">
  117 + <xsl:if test="not(.=$parent/namespace::*) and name()!='geonet'">
  118 + <xsl:text> xmlns</xsl:text>
  119 + <xsl:if test="name()">
  120 + <xsl:text>:</xsl:text>
  121 + <xsl:value-of select="name()"/>
  122 + </xsl:if>
  123 + <xsl:text>=</xsl:text>
  124 + <font color="#888844">
  125 + <xsl:text>"</xsl:text>
  126 + <xsl:value-of select="string()"/>
  127 + <xsl:text>"</xsl:text>
  128 + </font>
  129 + </xsl:if>
  130 + </xsl:for-each>
  131 + </xsl:template>
  132 +
  133 +</xsl:stylesheet>
  134 +
... ...