[Jiemamy-notify] commit [2068] 名前空間いろいろ研究中。。。うまくいかん><

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 11月 3日 (月) 20:02:48 JST


Revision: 2068
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2068
Author:   daisuke_m
Date:     2008-11-03 20:02:47 +0900 (Mon, 03 Nov 2008)

Log Message:
-----------
名前空間いろいろ研究中。。。うまくいかん><

Modified Paths:
--------------
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ConstraintXmlElement.java
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/RootXmlElement.java
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/XmlElement.java


-------------- next part --------------
Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java	2008-10-31 16:43:17 UTC (rev 2067)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java	2008-11-03 11:02:47 UTC (rev 2068)
@@ -38,12 +38,6 @@
  */
 public class ModelWriter {
 	
-	private static final String CORE_NAMESPACE = "http://jiemamy.org/ns/core/v1";
-	
-	private static final String EVENT_NAMESPACE = "http://jiemamy.org/ns/event/v1";
-	
-	private static final String VIEW_NAMESPACE = "http://jiemamy.org/ns/view/v1";
-	
 	/** 
 	 * 処理中のモデル構造スタック
 	 * 
@@ -80,9 +74,9 @@
 	 */
 	public ModelWriter(RootModel rootModel, Queue<Byte> resourceQueue) {
 		this.resourceQueue = resourceQueue;
-		dataWriter.setPrefix(CORE_NAMESPACE, "");
-		dataWriter.setPrefix(EVENT_NAMESPACE, "event");
-		dataWriter.setPrefix(VIEW_NAMESPACE, "view");
+//		dataWriter.setPrefix(CORE_NAMESPACE, "");
+//		dataWriter.setPrefix(EVENT_NAMESPACE, "event");
+//		dataWriter.setPrefix(VIEW_NAMESPACE, "view");
 		dataWriter.setIndentStep(2);
 		
 		StringWriter sw = new StringWriter();
@@ -153,15 +147,14 @@
 	private void write(XmlElement element) throws SAXException {
 		if (element.getState() == ElementState.INIT) {
 			if (element.hasNext()) {
-				dataWriter.startElement(CORE_NAMESPACE, element.getName(), element.getName(), element.getAttributes());
+				dataWriter.startElement("", element.getName(), element.getName(), element.getAttributes());
 				element.setState(ElementState.PROGRESS);
 				xmlStack.push(element.next());
 			} else {
 				if (element.isEmptyElement()) {
-					dataWriter.emptyElement(CORE_NAMESPACE, element.getName(), element.getName(), element
-						.getAttributes());
+					dataWriter.emptyElement("", element.getName(), element.getName(), element.getAttributes());
 				} else {
-					dataWriter.dataElement(CORE_NAMESPACE, element.getName(), element.toString());
+					dataWriter.dataElement("", element.getName(), element.toString());
 				}
 				element.setState(ElementState.FINISHED);
 				xmlStack.pop();
@@ -170,7 +163,7 @@
 			if (element.hasNext()) {
 				xmlStack.push(element.next());
 			} else {
-				dataWriter.endElement(CORE_NAMESPACE, element.getName(), element.getName());
+				dataWriter.endElement("", element.getName(), element.getName());
 				element.setState(ElementState.FINISHED);
 				xmlStack.pop();
 			}

Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ConstraintXmlElement.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ConstraintXmlElement.java	2008-10-31 16:43:17 UTC (rev 2067)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ConstraintXmlElement.java	2008-11-03 11:02:47 UTC (rev 2068)
@@ -44,7 +44,7 @@
 	 * @category instance creation
 	 */
 	public ConstraintXmlElement(String name, Constraint constraint, boolean byReference) {
-		super(name == null ? "column" : name, constraint, byReference);
+		super(name, constraint, byReference);
 		
 		if (byReference) {
 			addAttribute("ref", constraint.getId().toString());

Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/RootXmlElement.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/RootXmlElement.java	2008-10-31 16:43:17 UTC (rev 2067)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/RootXmlElement.java	2008-11-03 11:02:47 UTC (rev 2068)
@@ -46,15 +46,29 @@
 	public RootXmlElement(String name, RootModel rootModel, boolean byReference) {
 		super(name == null ? "rootModel" : name, rootModel, byReference);
 		
+		// xmlns="http://jiemamy.org/xml/ns/core" (J_URI)
+		// xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" (XSI_URI)
+		// xsi:schemaLocation="http://jiemamy.org/xml/ns/core jiemamy-core.xsd"
+		// という属性を出したい…。
+		
+		addAttribute(XMLNS_URI, "", "xmlns", "CDATA", J_URI);
+		addAttribute(XMLNS_URI, "", "xmlns:xsi", "CDATA", XSI_URI);
+		addAttribute(XSI_URI, "", "xsi:schemaLocation", "CDATA", J_URI + " jiemamy-core.xsd");
+		
+//		addAttribute("", "xmlns", "xmlns", "CDATA", J_URI);
+//		addAttribute("", "xsi", "xmlns:xsi", "CDATA", XSI_URI);
+//		addAttribute(XSI_URI, "", "xsi:schemaLocation", "CDATA", J_URI + " jiemamy-core.xsd");
+		
 		if (byReference) {
 			addAttribute("ref", rootModel.getId().toString());
 		} else {
 			addAttribute("id", rootModel.getId().toString());
-			queue.add(new XmlElement("rdbmsName", rootModel.getDialectClassName()));
+			
+			queue.add(new XmlElement("dialectClass", rootModel.getDialectClassName()));
+			queue.add(new XmlElement("schemaName", rootModel.getSchemaName()));
 			queue.add(new XmlElement("beginScript", rootModel.getBeginScript()));
 			queue.add(new XmlElement("endScript", rootModel.getEndScript()));
 			queue.add(new XmlElement("description", rootModel.getDescription()));
-			queue.add(new XmlElement("schemaName", rootModel.getSchemaName()));
 			queue.add(new CollectionXmlElement("domains", rootModel.getDomains()));
 			queue.add(new CollectionXmlElement("nodes", rootModel.getNodes()));
 			queue.add(new CollectionXmlElement("connections", rootModel.getConnections()));

Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/XmlElement.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/XmlElement.java	2008-10-31 16:43:17 UTC (rev 2067)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/XmlElement.java	2008-11-03 11:02:47 UTC (rev 2068)
@@ -34,8 +34,12 @@
  */
 public class XmlElement implements Iterator<XmlElement> {
 	
-	private static final String NAMESPACE = "http://jiemamy.org/ns/model/v1";
+	public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
 	
+	public static final String XSI_URI = "http://www.w3.org/2001/XMLSchema-instance";
+	
+	public static final String J_URI = "http://jiemamy.org/xml/ns/core";
+	
 	/** 
 	 * 未出力エレメントのキュー
 	 * 
@@ -92,10 +96,14 @@
 	}
 	
 	public void addAttribute(String key, String value) {
-		// DOCME 引数、よく分からずに使ってます><
-		attributes.addAttribute("", key, key, "", value);
+		// void addAttribute(String uri, String localName, String qName, String type, String value) 
+		attributes.addAttribute(J_URI, key, "j:" + key, "", value);
 	}
 	
+	public void addAttribute(String uri, String localName, String qName, String type, String value) {
+		attributes.addAttribute(uri, localName, qName, type, value);
+	}
+	
 	public Attributes getAttributes() {
 		return attributes;
 	}


Jiemamy-notify メーリングリストの案内
Back to archive index