From 0003925549ea009bb0a99c225b5d1992ccd8e7af Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sun, 28 Aug 2011 01:14:40 +0200 Subject: Preliminary code to populate a PostgreSQL database with weblog entries. --- org/madore/damlengine/DamlEngine.java | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'org/madore/damlengine/DamlEngine.java') diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index 69403f7..0837bd3 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -1,6 +1,8 @@ package org.madore.damlengine; import java.io.OutputStreamWriter; +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.Document; @@ -9,10 +11,34 @@ import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl; public final class DamlEngine { - public static final String XML_NS = "http://www.w3.org/XML/1998/namespace"; + public static final String XML_NS = XMLConstants.XML_NS_URI; public static final String XHTML_NS = "http://www.w3.org/1999/xhtml"; public static final String DAML_NS = "http://www.madore.org/~david/NS/daml/"; + public static final class DamlNSMapping implements NamespaceContext { + // This is used for XPath resolution (_not_ for parsing the document). + public String getNamespaceURI(String prefix) { + if ( prefix == null ) + throw new IllegalArgumentException("getNamespaceURI() called with null prefix"); + else if ( prefix.equals("") ) + return XHTML_NS; + else if ( prefix.equals("d") ) + return DAML_NS; + else if ( prefix.equals("xml") ) + return XML_NS; + else if ( prefix.equals("xmlns") ) + return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; + else + return XMLConstants.NULL_NS_URI; + } + public String getPrefix(String uri) { + throw new UnsupportedOperationException("getPrefix() not implemented"); + } + public java.util.Iterator getPrefixes(String uri) { + throw new UnsupportedOperationException("getPrefixes() not implemented"); + } + } + private DamlEngine() { // Forbid instantiation throw new AssertionError("DamlEngine cannot be instantiated"); } -- cgit v1.2.3