Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
* @author user04
*
*/
public class SimpleDom {
/**
* @param args
* @throws Exception
*/
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
try {
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
}
catch (IllegalArgumentException x) {
}
DocumentBuilder parser = factory.newDocumentBuilder();
parser.setErrorHandler(new ErrorHandler(){
public void error(SAXParseException arg0) throws SAXException {
System.out.println(arg0);
}
public void fatalError(SAXParseException arg0) throws SAXException {
System.out.println(arg0);
}
public void warning(SAXParseException arg0) throws SAXException {
System.out.println(arg0);
}
});
Document document=parser.parse(new File("test.xml"));
}
}
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
* @author user04
*
*/
public class SimpleDom {
/**
* @param args
* @throws Exception
*/
static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
try {
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, new File("test.xsd"));
}
catch (IllegalArgumentException x) {
}
DocumentBuilder parser = factory.newDocumentBuilder();
parser.setErrorHandler(new ErrorHandler(){
public void error(SAXParseException arg0) throws SAXException {
System.out.println(arg0);
}
public void fatalError(SAXParseException arg0) throws SAXException {
System.out.println(arg0);
}
public void warning(SAXParseException arg0) throws SAXException {
System.out.println(arg0);
}
});
Document document=parser.parse(new File("test.xml"));
}
}
import java.io.File;
import java.io.FileOutputStream;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class SimpleTransform {
static boolean valid = true;
public static void main(String[] args) throws Exception{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new File("test.xsd"));
factory.setSchema(schema);
DocumentBuilder parser = factory.newDocumentBuilder();
parser.setErrorHandler(new ErrorHandler(){
public void error(SAXParseException arg0) throws SAXException {
valid = false;
}
public void fatalError(SAXParseException arg0) throws SAXException {
valid = false;
}
public void warning(SAXParseException arg0) throws SAXException {
valid = false;
}
});
Document document = parser.parse("test.xml");
TransformerFactory factoryT = TransformerFactory.newInstance();
Transformer transformer = factoryT.newTransformer();
if(valid)
transformer.transform(new DOMSource(document), new StreamResult(new FileOutputStream("test.c")));
else
System.out.println("Not valid");
}
}