xslt - zobrazenie xml

Sekcia: Programovanie 12.01.2007 | 09:55
Avatar nahnevaný mladý muž gNewSense  Používateľ
Ahoj.

O xml vela neviem ale potrebujem ho (asi s pomocou xslt) zobrazit v browseri. Neviem ale ako mam pracovat s tymi vnutornymi tagmi (ci ako sa to vola). Tu je xml:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<FileListing>
<Directory Name="Auta">
<Directory Name="Nakladne">
<File Name="Vetrieska" />
<File Name="Liaz" />
</Directory>
<Directory Name="Osobne">
<Directory Name="Sportove">
<File Name="Ferari" />
<File Name="Lamborghini" />
</Directory>
<Directory Name="Sedany">
<File Name="Oktavia" />
</Directory>
<Directory Name="Vany">
<File Name="Felicia" />
<File Name="Punto" />
</Directory>
</Directory>
</Directory>
</FileListing>


Malo by to vyzerat asi takto:


Auta
Nakladne
Vetrieska
Liaz
Osobne
Sportove
Ferari
Lamborghini
Sedany
Oktavia
Vany
Felicia
Punto
    • Re: xslt - zobrazenie xml 12.01.2007 | 09:56
      Avatar nahnevaný mladý muž gNewSense  Používateľ
      "vnutornym tagom" som mal na mysli "Name"
    • Re: xslt - zobrazenie xml 26.01.2007 | 23:20
      Avatar lacodomin RedHat,Fedora  Používateľ
      potrebujes

      a) xml subor

      b) xsl file ktory popisuje transformaciu xml -> html

      c) nastroj/program na xml transformaciu



      fragment transformacneho kodu

      public void do_XSLT(java.io.OutputStream writer, InputStream xml, InputStream xsl, PortletURL actionURL) throws PortletException

      {

      try {

      // JAXP reads data using the Source interface

      Source xmlSource = new StreamSource(xml);

      Source xsltSource = new StreamSource(xsl);

      // the factory pattern supports different XSLT processors

      TransformerFactory transFact = TransformerFactory.newInstance();

      Transformer trans = transFact.newTransformer(xsltSource);

      trans.setParameter("action_url", actionURL.toString());

      trans.transform(xmlSource, new StreamResult(writer));

      } catch (Exception e) {

      System.out.println(e.toString());

      }

      }