ich ein XML-Dokument habe, die eine Liste von Kategorien hat:XSLT: Geht eine baumartige Struktur
<categories>
<category id="1" parent="0">Configurations</category>
<category id="11" parent="13">LCD Monitor</category>
<category id="12" parent="13">CRT Monitor</category>
<category id="13" parent="1"">Monitors</category>
<category id="123" parent="122">Printer</category>
...
</categories>
und eine Liste der Produkte:
<products>
<product>
...
<category>12</category>
...
</product>
...
</products>
Wenn die Kategorie Produkt ist gleich 12, dann sollte es in "Konfigurationen/Monitore/CRT Monitor" umgewandelt werden (nehmen Sie Kategorie 12, dann ist es Elternteil (13), etc.). Wenn das Elternteil 0 ist, hör auf.
Gibt es eine elegante Möglichkeit, dies mit einer XSL-Transformation zu tun?
+1 Deutlich eleganter als meine Antwort. – andynormancx