Announcement

Collapse
No announcement yet.

XML: XSL und DTD

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML: XSL und DTD

    Hallo zusammen,

    ich möchte in ein XML-Dokument, welches ich mit DOM in Java erzeuge, folgende Spezifikationen eintragen:

    <?xml-stylesheet type="text/xsl" href="first.xsl" ?>

    !DOCTYPE FIRST SYSTEM "first.dtd">

    Kann mir jemanden helfen, wie das geht ?
    <p>ich werde für jede Hilfe sehr dankbar.

    Gruss
    Zahid

  • #2
    Hallo,<br>
    <br>
    ich würde es folgendermassen vesuchen:<br>
    <br>
    Document doc = new DocumentImpl();<br>
    <br>
    ProcessingInstruction pi = doc.createProcessingInstruction("xsl:stylesheet"," href=\"foo.xsl\" type=\"text/xsl\"");<br>
    doc.appendChild(pi);<br>
    <br>
    Element root = doc.createElement("person");<br>
    doc.appendChild(root);<br>
    <br>
    OutputFormat format = new OutputFormat( doc ); <br>
    format.setDoctype(null,"test.dtd");<br>
    StringWriter stringOut = new StringWriter();<br>
    XMLSerializer serial = new XMLSerializer(stringOut, format);<br>
    serial.asDOMSerializer();<br>
    serial.serialize(doc);<br>
    System.out.println(stringOut.toString());<br>
    <br>
    Grus

    Comment


    • #3
      Hallo Michael,

      danke, es hat funktioniert ich muesste nur "xml-stylesheet" angeben anstatt "xsl:stylesheet". Die Anweisung sieht dann folgendermassen aus:

      Document doc = new DocumentImpl();

      ProcessingInstruction pi = doc.createProcessingInstruction("xml-stylesheet","href=\"foo.xsl\" type=\"text/xsl\"");
      doc.appendChild(pi);

      Gruss
      Zahi

      Comment

      Working...
      X