Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XML Tranformer liefert nur blanken Text

Empfohlene Antworten

Veröffentlicht

Hi,

ich hab n Problem mit dem XML Transformer.

Quellcode:

import java.io.File;

import java.util.Date;


import javax.xml.transform.Source;

import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.stream.StreamResult;

import javax.xml.transform.stream.StreamSource;


public class Transform {


    public static File main(File xmlFile, File xsltFile) throws Exception {

        // JAXP reads data using the Source interface

        Source xmlSource = new StreamSource(xmlFile);

        Source xsltSource = new StreamSource(xsltFile);


        // the factory pattern supports different XSLT processors

        TransformerFactory transFact = TransformerFactory.newInstance();

        Transformer trans = transFact.newTransformer(xsltSource);

        long start = new Date().getTime();

        String tmpFile = "C:\\tmp\\tmp_"+start+".tmp";

        File mappedXmlFile = new File(tmpFile);

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

        return mappedXmlFile;

    }

}

Ich hab die xmlFile mit dem entsprechenden xsltFile (habs mir in die Konsole ausgegebn) im XML-Spy durcharbeiten lassen und das Ergebniss war eine schöne, tolle XML Datei, so wie ich sie haben will.

Der oben stehende Quellcode hingegen haut mit nur die Freistehenden Texte raus.

Also aus zB: "<blub abc="ha">Was geht?</blub>" wird dann "Was geht?".

In der XSLT ist als Method auch XML angegeben.

Wo liegt da das Problem? Wieso bekomm ich keine ordentliche XML Datei raus, wie im Spy?

PS: Java ist 1.5.0_06

kannste dem tranformer nicht nen "content-type" setzen ?

wie sieht die xsl aus ?

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.