Ich hab jetzt nochmal rausgenommen, was ich nicht verstanden habe, und eine and-Suche ins xsl gebastelt. Mit den ':' als Trennzeichen sollte das jetzt auch in soweit funktionieren, dass keine Substrings in den Tags gesucht werden.
An Vorschlägen bin ich natürlich weiter interessiert, aber ansonsten bin ich erstmal zufrieden, was das xml angeht. Danke nochmal fürs Mithelfen.
Meine aktuelle Version:
-----------------gallery.html-------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Bildergalerie</title>
<script language="JavaScript" type="text/javascript">
var XMLDatei = "pics.xml"; // Pafad zur XML-Datei
var XSLDatei = "pics.xsl"; // Pafad zur XSL-Datei
var objectXML;
var objectXSL;
var objectXSLCache;
var objectXSLTProcessor;
var HTMLAusgabe;
var mytags = "";
function transformation() {
// Abfrage für den Internet Explorer
if (window.ActiveXObject) {
// XML laden
objectXML = new ActiveXObject("MSXML2.DOMDocument");
objectXML.async = false;
objectXML.load(XMLDatei);
// XSL laden
objectXSL = new ActiveXObject("MSXML2.FreeThreadedDOMDocument.4.0");
objectXSL.async = false;
objectXSL.load(XSLDatei);
//cachen das XSLT für bessere performance
objectXSLCache = new ActiveXObject("Msxml2.XSLTemplate.4.0");
objectXSLCache.stylesheet = objectXSL;
}
// Abfrage für Mozilla / Netscape
else if (window.ChromeWindow) {
// Im Mozilla erst XSL laden
objectXSLTProcessor = new XSLTProcessor();
objectXSL = new XMLHttpRequest();
objectXSL.open("GET", XSLDatei, false);
objectXSL.send(null);
objectXSL = objectXSL.responseXML;
objectXSLTProcessor.importStylesheet(objectXSL);
// XML laden
objectXML = new XMLHttpRequest();
objectXML.open("GET", XMLDatei, false);
objectXML.send(null);
objectXML = objectXML.responseXML;
}
else {
alert("Ihr Browser unterstützt leider keine XML-XSL-Transformation mittels JavaScript");
}
refreshresults(); //führt die 1. tranformation aus mit dem wert aus dem ui.formular
}
function refreshresults() {
mytags=":";
if(document.ui.birds.checked) {
mytags+="birds:";
}
if(document.ui.cats.checked && (bCats == false)) {
mytags+="cats:";
}
if(document.ui.nature.checked) {
mytags+="nature:";
}
if (window.ActiveXObject) {
objectXSLTProcessor = objectXSLCache.createProcessor();
objectXSLTProcessor.input = objectXML;
objectXSLTProcessor.addParameter("album", document.ui.album.value, "");
objectXSLTProcessor.addParameter("tags", mytags, "");
objectXSLTProcessor.addParameter("searchmode", document.ui.searchmode.value, "");
objectXSLTProcessor.transform();
document.getElementById("results").innerHTML = objectXSLTProcessor.output;
}
else if (window.ChromeWindow) {
var myParam = objectXSLTProcessor.getParameter(null, "album");
objectXSLTProcessor.setParameter(null, "album", document.ui.album.value);
var myParam2 = objectXSLTProcessor.getParameter(null, "tags");
objectXSLTProcessor.setParameter(null, "tags", mytags);
var myParam3 = objectXSLTProcessor.getParameter(null, "searchmode");
objectXSLTProcessor.setParameter(null, "searchmode", document.ui.searchmode.value);
HTMLAusgabe = objectXSLTProcessor.transformToFragment(objectXML, document);
document.getElementById("results").innerHTML = "";
document.getElementById("results").appendChild(HTMLAusgabe);
}
}
function showmed(title) {
var html = "<img src="" + title + "" border="0">";
document.getElementById("med").innerHTML = html;
}
</script>
<style type="text/css">
html, body {
height:100%;
margin:0px;
padding:0px;
}
body { background-color:#909090; }
#albumform {
width:95px;
padding:0px 0px 0px 5px;
height:100%;
margin:0px;
background-color:#E0E0E0;
float:left;
}
#results {
width:100px;
height:100%;
margin:0px;
background-color:#c0c0c0;
float:left;
text-align:center;
}
#med {
height:100%;
width:auto;
margin:0px;
background-color:#909090;
float:left;
}
</style>
</head>
<body onload="transformation();">
<div id="albumform">
Album:
<form name="ui" action="">
<select name="album" onchange="refreshresults();">
<option value="all">All</option>
<option value="indoor">Indoor</option>
<option value="outdoor">Outdoor</option>
</select>
Search Mode:
<select name="searchmode" onchange="refreshresults();">
<option value="and">And</option>
<option value="or">Or</option>
</select><br>
<input type="checkbox" id="birds" onclick="refreshresults();">Birds<br>
<input type="checkbox" id="cats" onclick="refreshresults();">Cats<br>
<input type="checkbox" id="nature" onclick="refreshresults();" >Nature
</form>
</div>
<div id="results"></div>
<div id="med"></div>
<br clear="all">
</body>
</html>
------------------ pics.xsl --------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Bildergalerie</title>
<script language="JavaScript" type="text/javascript">
var XMLDatei = "pics.xml"; // Pafad zur XML-Datei
var XSLDatei = "pics.xsl"; // Pafad zur XSL-Datei
var objectXML;
var objectXSL;
var objectXSLCache;
var objectXSLTProcessor;
var HTMLAusgabe;
var mytags = "";
var bBirds = false;
var bCats = false;
var bNature = false;
function transformation() {
// Abfrage für den Internet Explorer
if (window.ActiveXObject) {
// XML laden
objectXML = new ActiveXObject("MSXML2.DOMDocument");
objectXML.async = false;
objectXML.load(XMLDatei);
// XSL laden
objectXSL = new ActiveXObject("MSXML2.FreeThreadedDOMDocument.4.0");
objectXSL.async = false;
objectXSL.load(XSLDatei);
//cachen das XSLT für bessere performance
objectXSLCache = new ActiveXObject("Msxml2.XSLTemplate.4.0");
objectXSLCache.stylesheet = objectXSL;
}
// Abfrage für Mozilla / Netscape
else if (window.ChromeWindow) {
// Im Mozilla erst XSL laden
objectXSLTProcessor = new XSLTProcessor();
objectXSL = new XMLHttpRequest();
objectXSL.open("GET", XSLDatei, false);
objectXSL.send(null);
objectXSL = objectXSL.responseXML;
objectXSLTProcessor.importStylesheet(objectXSL);
// XML laden
objectXML = new XMLHttpRequest();
objectXML.open("GET", XMLDatei, false);
objectXML.send(null);
objectXML = objectXML.responseXML;
}
else {
alert("Ihr Browser unterstützt leider keine XML-XSL-Transformation mittels JavaScript");
}
refreshresults(); //führt die 1. tranformation aus mit dem wert aus dem ui.formular
}
function refreshresults() {
mytags=":";
if(document.ui.birds.checked) {
mytags+="birds:";
}
if(document.ui.cats.checked && (bCats == false)) {
mytags+="cats:";
}
if(document.ui.nature.checked) {
mytags+="nature:";
}
if (window.ActiveXObject) {
objectXSLTProcessor = objectXSLCache.createProcessor();
objectXSLTProcessor.input = objectXML;
objectXSLTProcessor.addParameter("album", document.ui.album.value, "");
objectXSLTProcessor.addParameter("tags", mytags, "");
objectXSLTProcessor.addParameter("searchmode", document.ui.searchmode.value, "");
objectXSLTProcessor.transform();
document.getElementById("results").innerHTML = objectXSLTProcessor.output;
}
else if (window.ChromeWindow) {
var myParam = objectXSLTProcessor.getParameter(null, "album");
objectXSLTProcessor.setParameter(null, "album", document.ui.album.value);
var myParam2 = objectXSLTProcessor.getParameter(null, "tags");
objectXSLTProcessor.setParameter(null, "tags", mytags);
var myParam3 = objectXSLTProcessor.getParameter(null, "searchmode");
objectXSLTProcessor.setParameter(null, "searchmode", document.ui.searchmode.value);
HTMLAusgabe = objectXSLTProcessor.transformToFragment(objectXML, document);
document.getElementById("results").innerHTML = "";
document.getElementById("results").appendChild(HTMLAusgabe);
}
}
function showmed(title) {
var html = "<img src="" + title + "" border="0">";
document.getElementById("med").innerHTML = html;
}
</script>
<style type="text/css">
html, body {
height:100%;
margin:0px;
padding:0px;
}
body { background-color:#909090; }
#albumform {
width:95px;
padding:0px 0px 0px 5px;
height:100%;
margin:0px;
background-color:#E0E0E0;
float:left;
}
#results {
width:100px;
height:100%;
margin:0px;
background-color:#c0c0c0;
float:left;
text-align:center;
}
#med {
height:100%;
width:auto;
margin:0px;
background-color:#909090;
float:left;
}
</style>
</head>
<body onload="transformation();">
<div id="albumform">
Album:
<form name="ui" action="">
<select name="album" onchange="refreshresults();">
<option value="all">All</option>
<option value="indoor">Indoor</option>
<option value="outdoor">Outdoor</option>
</select>
Search Mode:
<select name="searchmode" onchange="refreshresults();">
<option value="and">And</option>
<option value="or">Or</option>
</select><br>
<input type="checkbox" id="birds" onclick="refreshresults();">Birds<br>
<input type="checkbox" id="cats" onclick="refreshresults();">Cats<br>
<input type="checkbox" id="nature" onclick="refreshresults();" >Nature
</form>
</div>
<div id="results"></div>
<div id="med"></div>
<br clear="all">
</body>
</html>
-------- pics.xml ---------------------------------------------------------------
<?xml version='1.0'?>
<picdb>
<pic name="001.jpg" album="indoor">
<tag>birds</tag>
</pic>
<pic name="002.jpg" album="indoor">
<tag>birds</tag>
</pic>
<pic name="003.jpg" album="indoor">
<tag>birds</tag>
</pic>
<pic name="004.jpg" album="indoor">
<tag>cats</tag>
</pic>
<pic name="005.jpg" album="outdoor">
<tag>birds</tag>
<tag>nature</tag>
</pic>
<pic name="006.jpg" album="outdoor">
<tag>nature</tag>
</pic>
<pic name="007.jpg" album="outdoor">
</pic>
<pic name="008.jpg" album="outdoor">
</pic>
</picdb>