[Jiemamy-notify:2298] commit [3332] XML namespaceの整理。それに伴う、XpathUtilの廃止、SmartXpathの導入。(これでもビミョーだが)

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 21日 (火) 21:13:44 JST


Revision: 3332
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3332
Author:   daisuke_m
Date:     2009-04-21 21:13:44 +0900 (Tue, 21 Apr 2009)

Log Message:
-----------
XML namespaceの整理。それに伴う、XpathUtilの廃止、SmartXpathの導入。(これでもビミョーだが)

Modified Paths:
--------------
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/serializer/JiemamySerializerTest.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisExtender.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ArtemisView.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewDomSerializerEnhancer.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreNamespace.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java
    zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml
    zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewNamespace.java
    zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java

Added Paths:
-----------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/SmartXpath.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/SmartXpathTest.java

Removed Paths:
-------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/serializer/JiemamySerializerTest.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/serializer/JiemamySerializerTest.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/serializer/JiemamySerializerTest.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -30,7 +30,6 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPathConstants;
 
 import org.apache.commons.collections15.CollectionUtils;
 import org.apache.commons.io.FileUtils;
@@ -52,7 +51,7 @@
 import org.jiemamy.model.node.NodeAdapter;
 import org.jiemamy.model.node.StickyModel;
 import org.jiemamy.serializer.JiemamySerializer;
-import org.jiemamy.utils.XpathUtil;
+import org.jiemamy.utils.SmartXpath;
 
 /**
  * {@link JiemamySerializer}用のテスト抽象クラス。
@@ -87,6 +86,7 @@
 	 */
 	@Test
 	public void test01_シリアライズする() throws Exception {
+		SmartXpath smartXpath = new SmartXpath(jiemamy);
 		ViewTestModelBuilder mb = new ViewTestModelBuilder(jiemamy);
 		mb.build();
 		JiemamyFactory factory = jiemamy.getFactory();
@@ -112,24 +112,20 @@
 //		assertThat(document, hasXPath("/jiemamy/endScript", is("COMMIT;")));
 		assertThat(document, hasXPath("/jiemamy/description", is("Jiemamyテストモデル1")));
 		
-		NodeList domainNodes =
-				(NodeList) XpathUtil.XPATH.evaluate("/jiemamy/domains/domain", document, XPathConstants.NODESET);
+		NodeList domainNodes = smartXpath.getNodes(document, "/jiemamy/domains/domain");
 		assertThat(domainNodes.getLength(), is(2));
 		assertThat(document, hasXPath("/jiemamy/domains/domain[1]/@id", is(mb.domainId.getId().toString())));
 		assertThat(document, hasXPath("/jiemamy/domains/domain[2]/@id", is(mb.domainName.getId().toString())));
 		
 		// テーブルのチェック
-		NodeList tableNodes =
-				(NodeList) XpathUtil.XPATH.evaluate("/jiemamy/entities/table", document, XPathConstants.NODESET);
+		NodeList tableNodes = smartXpath.getNodes(document, "/jiemamy/entities/table");
 		assertThat(tableNodes.getLength(), is(2));
 		assertThat(document, hasXPath(XPATH_T_DEPT + "/name", is("T_DEPT")));
 		
-		NodeList columnNodes =
-				(NodeList) XpathUtil.XPATH.evaluate(XPATH_T_DEPT_COLUMNS, document, XPathConstants.NODESET);
+		NodeList columnNodes = smartXpath.getNodes(document, XPATH_T_DEPT_COLUMNS);
 		assertThat(columnNodes.getLength(), is(4));
 		
-		NodeList viewNodes =
-				(NodeList) XpathUtil.XPATH.evaluate("/jiemamy/entities/view", document, XPathConstants.NODESET);
+		NodeList viewNodes = smartXpath.getNodes(document, "/jiemamy/entities/view");
 		assertThat(viewNodes.getLength(), is(1));
 		assertThat(document, hasXPath("/jiemamy/entities/view/@id", is("516f7961-cb7b-48e2-990b-7fb0c750c3a4")));
 		assertThat(document, hasXPath("/jiemamy/entities/view/name", is("V_HIGH_SAL_EMP")));

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -18,6 +18,7 @@
  */
 package org.jiemamy;
 
+import java.util.Arrays;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,6 +36,8 @@
 import org.jiemamy.utils.enhancer.Enhance;
 import org.jiemamy.utils.enhancer.EnhanceException;
 import org.jiemamy.utils.enhancer.FactoryEnhancer;
+import org.jiemamy.xml.CoreNamespace;
+import org.jiemamy.xml.JiemamyNamespace;
 
 /**
  * Jiemamy仕様の参照実装(コードネーム:Artemis)を表す型。
@@ -61,7 +64,7 @@
 	private final EventBroker eventBroker = new EventBrokerImpl();
 	
 	/** 実装に施された拡張の配列 */
-	private final ArtemisExtender[] extensions;
+	private final ArtemisExtender[] extenders;
 	
 	/** 拡張をほどこされたファクトリの{@link Class} */
 	private Class<? extends JiemamyFactory> enhancedFactoryClass;
@@ -84,14 +87,14 @@
 	/**
 	 * インスタンスを生成する。
 	 * 
-	 * @param extensions Artemis拡張オブジェクト
+	 * @param extenders Artemis拡張オブジェクト
 	 */
-	public Artemis(ArtemisExtender... extensions) {
-		this.extensions = extensions;
+	public Artemis(ArtemisExtender... extenders) {
+		this.extenders = extenders;
 		
 		List<Enhance> allEnhances = CollectionsUtil.newArrayList();
-		for (ArtemisExtender enhance : extensions) {
-			allEnhances.addAll(enhance.getEnhances());
+		for (ArtemisExtender extender : extenders) {
+			allEnhances.addAll(extender.getEnhances());
 		}
 		
 		FactoryEnhancer<JiemamyFactory> enhancer =
@@ -128,6 +131,17 @@
 		return factory;
 	}
 	
+	public JiemamyNamespace[] getNamespaces() {
+		List<JiemamyNamespace> namespaces = CollectionsUtil.newArrayList();
+		namespaces.addAll(Arrays.asList(CoreNamespace.values()));
+		
+		for (ArtemisExtender extender : extenders) {
+			namespaces.addAll(Arrays.asList(extender.getNamespaces()));
+		}
+		
+		return namespaces.toArray(new JiemamyNamespace[namespaces.size()]);
+	}
+	
 	public ReferenceResolver getReferenceResolver() {
 		assert resolver != null;
 		return resolver;
@@ -139,7 +153,7 @@
 	
 	public Set<OptionalSpec> getSupportedSpecs() {
 		Set<OptionalSpec> supportedSpecs = CollectionsUtil.newHashSet();
-		for (ArtemisExtender enhance : extensions) {
+		for (ArtemisExtender enhance : extenders) {
 			supportedSpecs.addAll(enhance.getSpecs());
 		}
 		return supportedSpecs;
@@ -160,8 +174,6 @@
 		
 		private final int release = 0;
 		
-		private final boolean snapshotImplementation = true;
-		
 
 		private ArtemisVersion() {
 		}
@@ -179,7 +191,7 @@
 		}
 		
 		public boolean isSnapshot() {
-			return SNAPSHOT || snapshotImplementation;
+			return SNAPSHOT;
 		}
 		
 		@Override
@@ -190,7 +202,7 @@
 			sb.append(MINOR);
 			sb.append(".");
 			sb.append(release);
-			if (SNAPSHOT || snapshotImplementation) {
+			if (SNAPSHOT) {
 				sb.append("-SNAPSHOT");
 			}
 			return sb.toString();

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisExtender.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisExtender.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisExtender.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -22,6 +22,7 @@
 import java.util.Set;
 
 import org.jiemamy.utils.enhancer.Enhance;
+import org.jiemamy.xml.JiemamyNamespace;
 
 /**
  * Jiemamy {@link Artemis} Implementationに対する、拡張インターフェイス。
@@ -37,6 +38,13 @@
 	List<Enhance> getEnhances();
 	
 	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	JiemamyNamespace[] getNamespaces();
+	
+	/**
 	 * この拡張が実装する「追加仕様」の{@link Set}を取得する。
 	 * 
 	 * @return この拡張が実装する「追加仕様」の{@link Set}

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -365,7 +365,7 @@
 			List<ColumnModel> columns = TableUtil.getColumns(tableModel);
 			for (ColumnModel columnModel : columns) {
 				if (columnModel.getDataType().equals(domainRef)) {
-					BuiltinDataType domainDataType = (BuiltinDataType) domainModel.getDataType();
+					BuiltinDataType domainDataType = domainModel.getDataType();
 					BuiltinDataTypeMold mold = dialect.findDataTypeMold(domainDataType);
 					BuiltinDataType newDataType = factory.newDataType(mold);
 					

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -211,8 +211,8 @@
 						throw new UnexpectedConditionError("setAccessible(true)しているのでアクセスできるはず", e);
 					}
 					if (value != null) {
-						DomUtil.newChild(adapterElement, new QName(CoreNamespace.NS_CORE.getNamespaceURI(), field
-							.getName()), value);
+						DomUtil.newChild(adapterElement, new QName(CoreNamespace.NS_CORE.getNamespaceURI().toString(),
+								field.getName()), value);
 						existSpecificValue = true;
 					}
 				}
@@ -263,9 +263,13 @@
 		rootElement.setAttribute(CoreQName.ID.getQNameString(), rootModel.getId().toString());
 		rootElement.setAttribute(CoreQName.VERSION.getQNameString(), Version.SPEC);
 		rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-		// FIXME locationを正式なURLに
-		rootElement.setAttribute("xsi:schemaLocation", ""
-				+ "http://jiemamy.org/xml/ns/core ../../main/resources/jiemamy-core.xsd");
+		
+		StringBuilder sb = new StringBuilder();
+		sb.append(CoreNamespace.NS_CORE.getNamespaceURI().toString());
+		sb.append(" ");
+		sb.append(CoreNamespace.NS_CORE.getXmlSchemaLocation());
+		rootElement.setAttribute("xsi:schemaLocation", sb.toString());
+		
 		document.appendChild(rootElement);
 		
 		buildMiscSection(rootElement);

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -24,6 +24,7 @@
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpressionException;
@@ -80,9 +81,11 @@
 import org.jiemamy.utils.Adaptable;
 import org.jiemamy.utils.DomUtil;
 import org.jiemamy.utils.IterableNodeList;
-import org.jiemamy.utils.XpathUtil;
+import org.jiemamy.utils.SmartXpath;
+import org.jiemamy.utils.UUIDUtil;
 import org.jiemamy.utils.model.RootModelUtil;
 import org.jiemamy.xml.CoreQName;
+import org.jiemamy.xml.JiemamyQName;
 
 /**
  * Jiemamy XMLモデルのDOMから{@link RootModel}を生成するクラス。
@@ -97,84 +100,14 @@
 	
 	private static Logger logger = LoggerFactory.getLogger(JiemamyDomParser.class);
 	
-
-	private static void readAdapter(Element element, Adaptable jiemamyElement) {
-		NodeList adapterNodeList = XpathUtil.getNodes(element, "core:adapter");
-		Iterable<Node> adapterIterator = new IterableNodeList(adapterNodeList);
-		
-		for (Node adapterNode : adapterIterator) {
-			String className = DomUtil.getAttributeString((Element) adapterNode, CoreQName.CLASS);
-			try {
-				Class<?> clazz = Class.forName(className);
-				Object adapter;
-				if (jiemamyElement.hasAdapter(clazz)) {
-					adapter = jiemamyElement.getAdapter(clazz);
-				} else {
-					try {
-						adapter = clazz.newInstance();
-						jiemamyElement.registerAdapter(adapter);
-					} catch (InstantiationException e) {
-						logger.warn("ModelAdapter must have default constructor.", e);
-						continue;
-					} catch (IllegalAccessException e) {
-						logger.warn("ModelAdapter must be public.", e);
-						continue;
-					}
-				}
-				NodeList propertyNodes = adapterNode.getChildNodes();
-				Iterable<Node> propertyNodesIterator = new IterableNodeList(propertyNodes);
-				
-				for (Node propertyNode : propertyNodesIterator) {
-					if ((propertyNode instanceof Element) == false) {
-						continue;
-					}
-					Element propertyElement = (Element) propertyNode;
-					String fieldName = null;
-					try {
-						fieldName = propertyElement.getTagName();
-						Field field = adapter.getClass().getDeclaredField(fieldName);
-						field.setAccessible(true);
-						String value = propertyElement.getTextContent();
-						Class<?> type = field.getType();
-						if (type == Integer.class || type == int.class) {
-							field.set(adapter, NumberUtils.toInt(value));
-						} else if (type == Long.class || type == long.class) {
-							field.set(adapter, NumberUtils.toLong(value));
-						} else if (type == Float.class || type == float.class) {
-							field.set(adapter, NumberUtils.toFloat(value));
-						} else if (type == Double.class || type == double.class) {
-							field.set(adapter, NumberUtils.toDouble(value));
-						} else if (type == Boolean.class || type == boolean.class) {
-							field.set(adapter, BooleanUtils.toBoolean(value));
-						} else if (type == String.class) {
-							field.set(adapter, value);
-						} else {
-							logger.warn("unsupported model adapter field data type: " + field.getType().getName());
-						}
-					} catch (SecurityException e) {
-						logger.warn("security error", e);
-					} catch (NoSuchFieldException e) {
-						logger.warn("no such field " + fieldName + " in " + className, e);
-					} catch (IllegalArgumentException e) {
-						throw new UnexpectedConditionError("代入する型はifでチェックしているハズ。", e);
-					} catch (IllegalAccessException e) {
-						throw new UnexpectedConditionError("setAccessible(true)したハズ。", e);
-					}
-				}
-				
-			} catch (ClassNotFoundException e) {
-				logger.warn("class not found (ignored): " + className, e);
-			}
-		}
-	}
-	
-
 	private final Jiemamy jiemamy;
 	
 	private final JiemamyFactory factory;
 	
 	private final Document document;
 	
+	private SmartXpath smartXpath;
+	
 
 	/**
 	 * インスタンスを生成する。
@@ -188,6 +121,8 @@
 		this.jiemamy = jiemamy;
 		factory = jiemamy.getFactory();
 		this.document = document;
+		
+		smartXpath = new SmartXpath(jiemamy);
 	}
 	
 	/**
@@ -207,12 +142,12 @@
 	private DataType getDataType(Element element) {
 		try {
 			if (element.getChildNodes().getLength() == 0 && StringUtils.isEmpty(element.getAttribute("ref")) == false) {
-				return new DomainRefImpl(jiemamy, DomUtil.getUUID(element, CoreQName.REF));
+				return new DomainRefImpl(jiemamy, getUUID(element, CoreQName.REF));
 			} else {
 				String typeCategoryString =
-						(String) XpathUtil.XPATH.evaluate("core:typeCategory/text()", element, XPathConstants.STRING);
+						(String) smartXpath.xpath.evaluate("core:typeCategory/text()", element, XPathConstants.STRING);
 				String typeName =
-						(String) XpathUtil.XPATH.evaluate("core:typeName/text()", element, XPathConstants.STRING);
+						(String) smartXpath.xpath.evaluate("core:typeName/text()", element, XPathConstants.STRING);
 				
 				RootModel rootModel = factory.getRootModel();
 				Dialect dialect;
@@ -254,8 +189,23 @@
 		}
 	}
 	
+	/**
+	 * 要素の属性に設定された値を{@link UUID}として取得する。
+	 * 
+	 * @param domNode ノード
+	 * @param node 属性指定
+	 * @return {@link UUID}
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	private UUID getUUID(Node domNode, JiemamyQName node) {
+		Validate.notNull(node);
+		
+		String uuidStr = smartXpath.getAttr(domNode, "@" + node.getQNameString()).getValue();
+		return UUIDUtil.valueOfOrRandom(uuidStr);
+	}
+	
 	private void parseAttributes(Element tableElement, TableModel tableModel) {
-		NodeList attributeNodeList = XpathUtil.getNodes(tableElement, "core:attributes/*");
+		NodeList attributeNodeList = smartXpath.getNodes(tableElement, "core:attributes/*");
 		Iterable<Node> attributeIterableNodeList = new IterableNodeList(attributeNodeList);
 		for (Node attributeNode : attributeIterableNodeList) {
 			if ((attributeNode instanceof Element) == false) {
@@ -279,83 +229,80 @@
 	}
 	
 	private void parseColumn(Element columnElement, TableModel tableModel) {
-		ColumnModel columnModel = factory.newModel(ColumnModel.class, DomUtil.getUUID(columnElement, CoreQName.ID));
-		columnModel.setName(XpathUtil.getTextContent(columnElement, EL_CORE_NAME));
-		columnModel.setLogicalName(XpathUtil.getTextContent(columnElement, EL_CORE_LOGICALNAME));
-		columnModel.setDataType(getDataType((Element) XpathUtil.getNode(columnElement, "core:dataType")));
-		columnModel.setDefaultValue(XpathUtil.getTextContent(columnElement, "core:defaultValue"));
+		ColumnModel columnModel = factory.newModel(ColumnModel.class, getUUID(columnElement, CoreQName.ID));
+		columnModel.setName(smartXpath.getTextContent(columnElement, EL_CORE_NAME));
+		columnModel.setLogicalName(smartXpath.getTextContent(columnElement, EL_CORE_LOGICALNAME));
+		columnModel.setDataType(getDataType((Element) smartXpath.getNode(columnElement, "core:dataType")));
+		columnModel.setDefaultValue(smartXpath.getTextContent(columnElement, "core:defaultValue"));
 		
-		Element nnElement = (Element) XpathUtil.getNode(columnElement, "core:notNull");
+		Element nnElement = (Element) smartXpath.getNode(columnElement, "core:notNull");
 		if (nnElement != null) {
-			NotNullConstraint nnModel =
-					factory.newModel(NotNullConstraint.class, DomUtil.getUUID(nnElement, CoreQName.ID));
-			nnModel.setName(XpathUtil.getTextContent(nnElement, EL_CORE_NAME));
+			NotNullConstraint nnModel = factory.newModel(NotNullConstraint.class, getUUID(nnElement, CoreQName.ID));
+			nnModel.setName(smartXpath.getTextContent(nnElement, EL_CORE_NAME));
 			readAdapter(nnElement, nnModel);
 			columnModel.setNotNullConstraint(nnModel);
 		}
 		
-		Element ukElement = (Element) XpathUtil.getNode(columnElement, "core:columnUniqueKey");
+		Element ukElement = (Element) smartXpath.getNode(columnElement, "core:columnUniqueKey");
 		if (ukElement != null) {
-			UniqueKey uniqueKey = factory.newModel(UniqueKey.class, DomUtil.getUUID(ukElement, CoreQName.ID));
-			uniqueKey.setName(XpathUtil.getTextContent(ukElement, EL_CORE_NAME));
+			UniqueKey uniqueKey = factory.newModel(UniqueKey.class, getUUID(ukElement, CoreQName.ID));
+			uniqueKey.setName(smartXpath.getTextContent(ukElement, EL_CORE_NAME));
 			uniqueKey.getKeyColumns().add(factory.newReference(columnModel));
 			readAdapter(ukElement, uniqueKey);
 			columnModel.setUniqueKey(uniqueKey);
 		}
 		
-		Element pkElement = (Element) XpathUtil.getNode(columnElement, "core:columnPrimaryKey");
+		Element pkElement = (Element) smartXpath.getNode(columnElement, "core:columnPrimaryKey");
 		if (pkElement != null) {
-			PrimaryKey primaryKey = factory.newModel(PrimaryKey.class, DomUtil.getUUID(pkElement, CoreQName.ID));
-			primaryKey.setName(XpathUtil.getTextContent(pkElement, EL_CORE_NAME));
+			PrimaryKey primaryKey = factory.newModel(PrimaryKey.class, getUUID(pkElement, CoreQName.ID));
+			primaryKey.setName(smartXpath.getTextContent(pkElement, EL_CORE_NAME));
 			primaryKey.getKeyColumns().add(factory.newReference(columnModel));
 			readAdapter(pkElement, primaryKey);
 			columnModel.setPrimaryKey(primaryKey);
 		}
 		
-		Element checkElement = (Element) XpathUtil.getNode(columnElement, "core:columnCheck");
+		Element checkElement = (Element) smartXpath.getNode(columnElement, "core:columnCheck");
 		if (checkElement != null) {
 			ColumnCheckConstraint checkConstraint =
-					factory.newModel(ColumnCheckConstraint.class, DomUtil.getUUID(checkElement, CoreQName.ID));
-			checkConstraint.setName(XpathUtil.getTextContent(checkElement, EL_CORE_NAME));
-			checkConstraint.setExpression(XpathUtil.getTextContent(checkElement, "core:expression"));
+					factory.newModel(ColumnCheckConstraint.class, getUUID(checkElement, CoreQName.ID));
+			checkConstraint.setName(smartXpath.getTextContent(checkElement, EL_CORE_NAME));
+			checkConstraint.setExpression(smartXpath.getTextContent(checkElement, "core:expression"));
 			readAdapter(checkElement, checkConstraint);
 			columnModel.setCheckConstraint(checkConstraint);
 		}
 		
-		columnModel.setDescription(XpathUtil.getTextContent(columnElement, "core:description"));
+		columnModel.setDescription(smartXpath.getTextContent(columnElement, "core:description"));
 		readAdapter(columnElement, columnModel);
 		tableModel.getAttributes().add(columnModel);
 	}
 	
 	private void parseDataSetSection(RootModel rootModel) {
-		NodeList dataSetNodeList = XpathUtil.getNodes(document, "/core:jiemamy/core:dataSets/core:dataSet");
+		NodeList dataSetNodeList = smartXpath.getNodes(document, "/core:jiemamy/core:dataSets/core:dataSet");
 		Iterable<Node> dataSetIterableNodeList = new IterableNodeList(dataSetNodeList);
 		for (Node dataSetNode : dataSetIterableNodeList) {
 			
-			DataSetModel dataSetModel =
-					factory.newModel(DataSetModel.class, DomUtil.getUUID(dataSetNode, CoreQName.ID));
-			dataSetModel.setName(XpathUtil.getTextContent(dataSetNode, EL_CORE_NAME));
+			DataSetModel dataSetModel = factory.newModel(DataSetModel.class, getUUID(dataSetNode, CoreQName.ID));
+			dataSetModel.setName(smartXpath.getTextContent(dataSetNode, EL_CORE_NAME));
 			
-			NodeList tableRefNodeList = XpathUtil.getNodes(dataSetNode, "core:tableRef");
+			NodeList tableRefNodeList = smartXpath.getNodes(dataSetNode, "core:tableRef");
 			Iterable<Node> tableRefIterableNodeList = new IterableNodeList(tableRefNodeList);
 			for (Node tableRefNode : tableRefIterableNodeList) {
 				
-				TableRef tableRef = new TableRefImpl(jiemamy, DomUtil.getUUID(tableRefNode, CoreQName.REF));
+				TableRef tableRef = new TableRefImpl(jiemamy, getUUID(tableRefNode, CoreQName.REF));
 				List<RecordModel> recordModels = dataSetModel.getRecords().get(tableRef);
 				if (recordModels == null) {
 					recordModels = new ArrayList<RecordModel>();
 				}
 				
-				NodeList recordNodeList = XpathUtil.getNodes(tableRefNode, "core:record");
+				NodeList recordNodeList = smartXpath.getNodes(tableRefNode, "core:record");
 				Iterable<Node> recordIterableNodeList = new IterableNodeList(recordNodeList);
 				for (Node recordNode : recordIterableNodeList) {
-					RecordModel recordModel =
-							factory.newModel(RecordModel.class, DomUtil.getUUID(recordNode, CoreQName.ID));
+					RecordModel recordModel = factory.newModel(RecordModel.class, getUUID(recordNode, CoreQName.ID));
 					
-					NodeList columnRefNodeList = XpathUtil.getNodes(recordNode, "core:columnRef");
+					NodeList columnRefNodeList = smartXpath.getNodes(recordNode, "core:columnRef");
 					Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList);
 					for (Node columnRefNode : columnRefIterableNodeList) {
-						ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(columnRefNode, CoreQName.REF));
+						ColumnRef columnRef = new ColumnRefImpl(jiemamy, getUUID(columnRefNode, CoreQName.REF));
 						recordModel.getValues().put(columnRef, columnRefNode.getTextContent());
 					}
 					recordModels.add(recordModel);
@@ -368,15 +315,16 @@
 	}
 	
 	private void parseDeferrability(Element keyElement, KeyConstraint keyModel) {
-		Node deferrabilityElement = XpathUtil.getNode(keyElement, "core:deferrability");
+		Node deferrabilityElement = smartXpath.getNode(keyElement, "core:deferrability");
 		
 		if (deferrabilityElement != null) {
 			Deferrability deferrability =
-					factory.newModel(Deferrability.class, DomUtil.getUUID(deferrabilityElement, CoreQName.ID));
-			String deferrableString = XpathUtil.getTextContent(deferrabilityElement, "core:deferrable");
+					factory.newModel(Deferrability.class, getUUID(deferrabilityElement, CoreQName.ID));
+			String deferrableString = smartXpath.getTextContent(deferrabilityElement, "core:deferrable");
 			deferrability.setDeferrable(BooleanUtils.toBoolean(deferrableString));
 			
-			String initiallyCheckTimeString = XpathUtil.getTextContent(deferrabilityElement, "core:initiallyCheckTime");
+			String initiallyCheckTimeString =
+					smartXpath.getTextContent(deferrabilityElement, "core:initiallyCheckTime");
 			if (StringUtils.isEmpty(initiallyCheckTimeString) == false) {
 				deferrability.setInitiallyCheckTime(InitiallyCheckTime.valueOf(initiallyCheckTimeString));
 			}
@@ -387,37 +335,36 @@
 	}
 	
 	private void parseDomainSection(RootModel rootModel) {
-		NodeList domainsNodeList = XpathUtil.getNodes(document, "/core:jiemamy/core:domains/core:domain");
+		NodeList domainsNodeList = smartXpath.getNodes(document, "/core:jiemamy/core:domains/core:domain");
 		Iterable<Node> domainsIterableNodeList = new IterableNodeList(domainsNodeList);
 		for (Node domainNode : domainsIterableNodeList) {
-			DomainModel domainModel = factory.newModel(DomainModel.class, DomUtil.getUUID(domainNode, CoreQName.ID));
-			domainModel.setName(XpathUtil.getTextContent(domainNode, EL_CORE_NAME));
-			domainModel.setLogicalName(XpathUtil.getTextContent(domainNode, EL_CORE_LOGICALNAME));
-			domainModel.setDataType((BuiltinDataType) getDataType((Element) XpathUtil.getNode(domainNode,
+			DomainModel domainModel = factory.newModel(DomainModel.class, getUUID(domainNode, CoreQName.ID));
+			domainModel.setName(smartXpath.getTextContent(domainNode, EL_CORE_NAME));
+			domainModel.setLogicalName(smartXpath.getTextContent(domainNode, EL_CORE_LOGICALNAME));
+			domainModel.setDataType((BuiltinDataType) getDataType((Element) smartXpath.getNode(domainNode,
 					"core:dataType")));
 			
-			Node nnNode = XpathUtil.getNode(domainNode, "core:notNull");
+			Node nnNode = smartXpath.getNode(domainNode, "core:notNull");
 			if (nnNode != null) {
 				Element nnElement = (Element) nnNode;
-				NotNullConstraint nnModel =
-						factory.newModel(NotNullConstraint.class, DomUtil.getUUID(nnNode, CoreQName.ID));
-				nnModel.setName(XpathUtil.getTextContent(nnElement, EL_CORE_NAME));
+				NotNullConstraint nnModel = factory.newModel(NotNullConstraint.class, getUUID(nnNode, CoreQName.ID));
+				nnModel.setName(smartXpath.getTextContent(nnElement, EL_CORE_NAME));
 				readAdapter(nnElement, nnModel);
 				domainModel.setNotNullConstraint(nnModel);
 			}
 			
-			Node checkNode = XpathUtil.getNode(domainNode, "core:columnCheck");
+			Node checkNode = smartXpath.getNode(domainNode, "core:columnCheck");
 			if (checkNode != null) {
 				Element checkElement = (Element) checkNode;
 				ColumnCheckConstraint checkConstraint =
-						factory.newModel(ColumnCheckConstraint.class, DomUtil.getUUID(checkNode, CoreQName.ID));
-				checkConstraint.setExpression(XpathUtil.getTextContent(checkElement, "core:expression"));
+						factory.newModel(ColumnCheckConstraint.class, getUUID(checkNode, CoreQName.ID));
+				checkConstraint.setExpression(smartXpath.getTextContent(checkElement, "core:expression"));
 				readAdapter(checkElement, checkConstraint);
-				checkConstraint.setName(XpathUtil.getTextContent(checkElement, EL_CORE_NAME));
+				checkConstraint.setName(smartXpath.getTextContent(checkElement, EL_CORE_NAME));
 				domainModel.setCheckConstraint(checkConstraint);
 			}
 			
-			domainModel.setDescription(XpathUtil.getTextContent(domainNode, "core:description"));
+			domainModel.setDescription(smartXpath.getTextContent(domainNode, "core:description"));
 			
 			readAdapter((Element) domainNode, domainModel);
 			rootModel.getDomains().add(domainModel);
@@ -425,7 +372,7 @@
 	}
 	
 	private void parseEntitiesSection(RootModel rootModel) {
-		NodeList entitityNodeList = XpathUtil.getNodes(document, "/core:jiemamy/core:entities/*");
+		NodeList entitityNodeList = smartXpath.getNodes(document, "/core:jiemamy/core:entities/*");
 		Iterable<Node> entitityIterableNodeList = new IterableNodeList(entitityNodeList);
 		for (Node entityNode : entitityIterableNodeList) {
 			if ((entityNode instanceof Element) == false) {
@@ -450,30 +397,30 @@
 	}
 	
 	private void parseForeignKey(Element fkElement, TableModel tableModel) {
-		ForeignKey foreignKey = factory.newModel(ForeignKey.class, DomUtil.getUUID(fkElement, CoreQName.ID));
-		foreignKey.setName(XpathUtil.getTextContent(fkElement, EL_CORE_NAME));
-		foreignKey.setLogicalName(XpathUtil.getTextContent(fkElement, EL_CORE_LOGICALNAME));
-		NodeList columnRefNodeList = XpathUtil.getNodes(fkElement, "core:columnRefs/core:columnRef");
+		ForeignKey foreignKey = factory.newModel(ForeignKey.class, getUUID(fkElement, CoreQName.ID));
+		foreignKey.setName(smartXpath.getTextContent(fkElement, EL_CORE_NAME));
+		foreignKey.setLogicalName(smartXpath.getTextContent(fkElement, EL_CORE_LOGICALNAME));
+		NodeList columnRefNodeList = smartXpath.getNodes(fkElement, "core:columnRefs/core:columnRef");
 		Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList);
 		for (Node node : columnRefIterableNodeList) {
-			ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF));
+			ColumnRef columnRef = new ColumnRefImpl(jiemamy, getUUID(node, CoreQName.REF));
 			foreignKey.getKeyColumns().add(columnRef);
 		}
-		NodeList referenceColumnRefNodeList = XpathUtil.getNodes(fkElement, "core:referenceColumns/core:columnRef");
+		NodeList referenceColumnRefNodeList = smartXpath.getNodes(fkElement, "core:referenceColumns/core:columnRef");
 		Iterable<Node> referenceColumnRefIterableNodeList = new IterableNodeList(referenceColumnRefNodeList);
 		for (Node node : referenceColumnRefIterableNodeList) {
-			ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF));
+			ColumnRef columnRef = new ColumnRefImpl(jiemamy, getUUID(node, CoreQName.REF));
 			foreignKey.getReferenceColumns().add(columnRef);
 		}
 		
 		parseDeferrability(fkElement, foreignKey);
 		
-		String onDeleteString = XpathUtil.getTextContent(fkElement, "core:onDelete");
+		String onDeleteString = smartXpath.getTextContent(fkElement, "core:onDelete");
 		if (StringUtils.isEmpty(onDeleteString) == false) {
 			foreignKey.setOnDelete(ReferentialAction.valueOf(onDeleteString));
 		}
 		
-		String onUpdateString = XpathUtil.getTextContent(fkElement, "core:onUpdate");
+		String onUpdateString = smartXpath.getTextContent(fkElement, "core:onUpdate");
 		if (StringUtils.isEmpty(onUpdateString) == false) {
 			foreignKey.setOnUpdate(ReferentialAction.valueOf(onUpdateString));
 		}
@@ -483,28 +430,28 @@
 	}
 	
 	private void parseIndexes(Element tableElement, TableModel tableModel) {
-		NodeList indexNodeList = XpathUtil.getNodes(tableElement, "core:indexes/*");
+		NodeList indexNodeList = smartXpath.getNodes(tableElement, "core:indexes/*");
 		Iterable<Node> indexIterableNodeList = new IterableNodeList(indexNodeList);
 		for (Node indexNode : indexIterableNodeList) {
 			if ((indexNode instanceof Element) == false) {
 				continue;
 			}
 			Element indexElement = (Element) indexNode;
-			IndexModel indexModel = factory.newModel(IndexModel.class, DomUtil.getUUID(indexElement, CoreQName.ID));
-			indexModel.setName(XpathUtil.getTextContent(indexElement, EL_CORE_NAME));
-			indexModel.setUnique(BooleanUtils.toBoolean(XpathUtil.getTextContent(indexElement, "core:unique")));
+			IndexModel indexModel = factory.newModel(IndexModel.class, getUUID(indexElement, CoreQName.ID));
+			indexModel.setName(smartXpath.getTextContent(indexElement, EL_CORE_NAME));
+			indexModel.setUnique(BooleanUtils.toBoolean(smartXpath.getTextContent(indexElement, "core:unique")));
 			
-			NodeList indexColumnNodeList = XpathUtil.getNodes(indexElement, "core:indexColumns/core:indexColumn");
+			NodeList indexColumnNodeList = smartXpath.getNodes(indexElement, "core:indexColumns/core:indexColumn");
 			Iterable<Node> indexColumnIterableNodeList = new IterableNodeList(indexColumnNodeList);
 			for (Node node : indexColumnIterableNodeList) {
 				IndexColumnModel indexColumnModel =
-						factory.newModel(IndexColumnModel.class, DomUtil.getUUID(node, CoreQName.ID));
-				Node columnRefNode = XpathUtil.getNode(node, "core:columnRef");
-				ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(columnRefNode, CoreQName.REF));
+						factory.newModel(IndexColumnModel.class, getUUID(node, CoreQName.ID));
+				Node columnRefNode = smartXpath.getNode(node, "core:columnRef");
+				ColumnRef columnRef = new ColumnRefImpl(jiemamy, getUUID(columnRefNode, CoreQName.REF));
 				indexColumnModel.setColumnRef(columnRef);
 				indexModel.getIndexColumns().add(indexColumnModel);
 				
-				String sortOrderString = XpathUtil.getTextContent(node, "core:sortOrder");
+				String sortOrderString = smartXpath.getTextContent(node, "core:sortOrder");
 				if (StringUtils.isEmpty(sortOrderString) == false) {
 					indexColumnModel.setSortOrder(SortOrder.valueOf(sortOrderString));
 				}
@@ -515,13 +462,13 @@
 	}
 	
 	private void parsePrimaryKey(Element pkElement, TableModel tableModel) {
-		PrimaryKey primaryKey = factory.newModel(PrimaryKey.class, DomUtil.getUUID(pkElement, CoreQName.ID));
-		primaryKey.setName(XpathUtil.getTextContent(pkElement, EL_CORE_NAME));
-		primaryKey.setLogicalName(XpathUtil.getTextContent(pkElement, EL_CORE_LOGICALNAME));
-		NodeList columnRefNodeList = XpathUtil.getNodes(pkElement, "core:columnRefs/core:columnRef");
+		PrimaryKey primaryKey = factory.newModel(PrimaryKey.class, getUUID(pkElement, CoreQName.ID));
+		primaryKey.setName(smartXpath.getTextContent(pkElement, EL_CORE_NAME));
+		primaryKey.setLogicalName(smartXpath.getTextContent(pkElement, EL_CORE_LOGICALNAME));
+		NodeList columnRefNodeList = smartXpath.getNodes(pkElement, "core:columnRefs/core:columnRef");
 		Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList);
 		for (Node node : columnRefIterableNodeList) {
-			ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF));
+			ColumnRef columnRef = new ColumnRefImpl(jiemamy, getUUID(node, CoreQName.REF));
 			primaryKey.getKeyColumns().add(columnRef);
 		}
 		
@@ -534,28 +481,28 @@
 	private RootModel parseRoot() throws SerializationException {
 		Element rootElement = document.getDocumentElement();
 		
-		Attr verAttribute = XpathUtil.getAttr(document, "/core:jiemamy/@version");
+		Attr verAttribute = smartXpath.getAttr(document, "/core:jiemamy/@version");
 		String version = verAttribute.getValue();
 		if (Version.SPEC.equals(version) == false) {
 			throw new SerializationException("Version mismatch: serializer=" + Version.SPEC + ", xml=" + version);
 		}
-		RootModel rootModel = factory.getRootModel(DomUtil.getUUID(rootElement, CoreQName.ID));
-		rootModel.setDialectClassName(XpathUtil.getTextContent(document, "/core:jiemamy/core:dialect"));
-		rootModel.setSchemaName(XpathUtil.getTextContent(document, "/core:jiemamy/core:schemaName"));
-		rootModel.setBeginScript(XpathUtil.getTextContent(document, "/core:jiemamy/core:beginScript"));
-		rootModel.setEndScript(XpathUtil.getTextContent(document, "/core:jiemamy/core:endScript"));
-		rootModel.setDescription(XpathUtil.getTextContent(document, "/core:jiemamy/core:description"));
+		RootModel rootModel = factory.getRootModel(getUUID(rootElement, CoreQName.ID));
+		rootModel.setDialectClassName(smartXpath.getTextContent(document, "/core:jiemamy/core:dialect"));
+		rootModel.setSchemaName(smartXpath.getTextContent(document, "/core:jiemamy/core:schemaName"));
+		rootModel.setBeginScript(smartXpath.getTextContent(document, "/core:jiemamy/core:beginScript"));
+		rootModel.setEndScript(smartXpath.getTextContent(document, "/core:jiemamy/core:endScript"));
+		rootModel.setDescription(smartXpath.getTextContent(document, "/core:jiemamy/core:description"));
 		
 		return rootModel;
 	}
 	
 	private TableModel parseTable(Element tableElement) {
-		TableModel tableModel = factory.newModel(TableModel.class, DomUtil.getUUID(tableElement, CoreQName.ID));
-		tableModel.setName(XpathUtil.getTextContent(tableElement, EL_CORE_NAME));
-		tableModel.setLogicalName(XpathUtil.getTextContent(tableElement, EL_CORE_LOGICALNAME));
-		tableModel.setBeginScript(XpathUtil.getTextContent(tableElement, "core:beginScript"));
-		tableModel.setEndScript(XpathUtil.getTextContent(tableElement, "core:endScript"));
-		tableModel.setDescription(XpathUtil.getTextContent(tableElement, "core:description"));
+		TableModel tableModel = factory.newModel(TableModel.class, getUUID(tableElement, CoreQName.ID));
+		tableModel.setName(smartXpath.getTextContent(tableElement, EL_CORE_NAME));
+		tableModel.setLogicalName(smartXpath.getTextContent(tableElement, EL_CORE_LOGICALNAME));
+		tableModel.setBeginScript(smartXpath.getTextContent(tableElement, "core:beginScript"));
+		tableModel.setEndScript(smartXpath.getTextContent(tableElement, "core:endScript"));
+		tableModel.setDescription(smartXpath.getTextContent(tableElement, "core:description"));
 		
 		parseAttributes(tableElement, tableModel);
 		parseIndexes(tableElement, tableModel);
@@ -566,22 +513,22 @@
 	
 	private void parseTableCheckConstraint(Element checkElement, TableModel tableModel) {
 		TableCheckConstraint checkConstraint =
-				factory.newModel(TableCheckConstraint.class, DomUtil.getUUID(checkElement, CoreQName.ID));
-		checkConstraint.setName(XpathUtil.getTextContent(checkElement, EL_CORE_NAME));
-		checkConstraint.setLogicalName(XpathUtil.getTextContent(checkElement, EL_CORE_LOGICALNAME));
-		checkConstraint.setExpression(XpathUtil.getTextContent(checkElement, "core:expression"));
+				factory.newModel(TableCheckConstraint.class, getUUID(checkElement, CoreQName.ID));
+		checkConstraint.setName(smartXpath.getTextContent(checkElement, EL_CORE_NAME));
+		checkConstraint.setLogicalName(smartXpath.getTextContent(checkElement, EL_CORE_LOGICALNAME));
+		checkConstraint.setExpression(smartXpath.getTextContent(checkElement, "core:expression"));
 		readAdapter(checkElement, checkConstraint);
 		tableModel.getAttributes().add(checkConstraint);
 	}
 	
 	private void parseUniqueKey(Element ukElement, TableModel tableModel) {
-		UniqueKey uniqueKey = factory.newModel(UniqueKey.class, DomUtil.getUUID(ukElement, CoreQName.ID));
-		uniqueKey.setName(XpathUtil.getTextContent(ukElement, EL_CORE_NAME));
-		uniqueKey.setLogicalName(XpathUtil.getTextContent(ukElement, EL_CORE_LOGICALNAME));
-		NodeList columnRefNodeList = XpathUtil.getNodes(ukElement, "core:columnRefs/core:columnRef");
+		UniqueKey uniqueKey = factory.newModel(UniqueKey.class, getUUID(ukElement, CoreQName.ID));
+		uniqueKey.setName(smartXpath.getTextContent(ukElement, EL_CORE_NAME));
+		uniqueKey.setLogicalName(smartXpath.getTextContent(ukElement, EL_CORE_LOGICALNAME));
+		NodeList columnRefNodeList = smartXpath.getNodes(ukElement, "core:columnRefs/core:columnRef");
 		Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList);
 		for (Node node : columnRefIterableNodeList) {
-			ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF));
+			ColumnRef columnRef = new ColumnRefImpl(jiemamy, getUUID(node, CoreQName.REF));
 			uniqueKey.getKeyColumns().add(columnRef);
 		}
 		
@@ -592,15 +539,86 @@
 	}
 	
 	private ViewModel parseView(Element viewElement) {
-		ViewModel viewModel = factory.newModel(ViewModel.class, DomUtil.getUUID(viewElement, CoreQName.ID));
-		viewModel.setName(XpathUtil.getTextContent(viewElement, EL_CORE_NAME));
-		viewModel.setLogicalName(XpathUtil.getTextContent(viewElement, EL_CORE_LOGICALNAME));
-		viewModel.setBeginScript(XpathUtil.getTextContent(viewElement, "core:beginScript"));
-		viewModel.setEndScript(XpathUtil.getTextContent(viewElement, "core:endScript"));
-		viewModel.setDescription(XpathUtil.getTextContent(viewElement, "core:description"));
-		viewModel.setDefinition(XpathUtil.getTextContent(viewElement, "core:definition"));
+		ViewModel viewModel = factory.newModel(ViewModel.class, getUUID(viewElement, CoreQName.ID));
+		viewModel.setName(smartXpath.getTextContent(viewElement, EL_CORE_NAME));
+		viewModel.setLogicalName(smartXpath.getTextContent(viewElement, EL_CORE_LOGICALNAME));
+		viewModel.setBeginScript(smartXpath.getTextContent(viewElement, "core:beginScript"));
+		viewModel.setEndScript(smartXpath.getTextContent(viewElement, "core:endScript"));
+		viewModel.setDescription(smartXpath.getTextContent(viewElement, "core:description"));
+		viewModel.setDefinition(smartXpath.getTextContent(viewElement, "core:definition"));
 		readAdapter(viewElement, viewModel);
 		return viewModel;
 	}
 	
+	private void readAdapter(Element element, Adaptable jiemamyElement) {
+		NodeList adapterNodeList = smartXpath.getNodes(element, "core:adapter");
+		Iterable<Node> adapterIterator = new IterableNodeList(adapterNodeList);
+		
+		for (Node adapterNode : adapterIterator) {
+			Attr attr = smartXpath.getAttr(adapterNode, "@" + CoreQName.CLASS.getQNameString());
+			String className = attr.getValue();
+			try {
+				Class<?> clazz = Class.forName(className);
+				Object adapter;
+				if (jiemamyElement.hasAdapter(clazz)) {
+					adapter = jiemamyElement.getAdapter(clazz);
+				} else {
+					try {
+						adapter = clazz.newInstance();
+						jiemamyElement.registerAdapter(adapter);
+					} catch (InstantiationException e) {
+						logger.warn("ModelAdapter must have default constructor.", e);
+						continue;
+					} catch (IllegalAccessException e) {
+						logger.warn("ModelAdapter must be public.", e);
+						continue;
+					}
+				}
+				NodeList propertyNodes = adapterNode.getChildNodes();
+				Iterable<Node> propertyNodesIterator = new IterableNodeList(propertyNodes);
+				
+				for (Node propertyNode : propertyNodesIterator) {
+					if ((propertyNode instanceof Element) == false) {
+						continue;
+					}
+					Element propertyElement = (Element) propertyNode;
+					String fieldName = null;
+					try {
+						fieldName = propertyElement.getTagName();
+						Field field = adapter.getClass().getDeclaredField(fieldName);
+						field.setAccessible(true);
+						String value = propertyElement.getTextContent();
+						Class<?> type = field.getType();
+						if (type == Integer.class || type == int.class) {
+							field.set(adapter, NumberUtils.toInt(value));
+						} else if (type == Long.class || type == long.class) {
+							field.set(adapter, NumberUtils.toLong(value));
+						} else if (type == Float.class || type == float.class) {
+							field.set(adapter, NumberUtils.toFloat(value));
+						} else if (type == Double.class || type == double.class) {
+							field.set(adapter, NumberUtils.toDouble(value));
+						} else if (type == Boolean.class || type == boolean.class) {
+							field.set(adapter, BooleanUtils.toBoolean(value));
+						} else if (type == String.class) {
+							field.set(adapter, value);
+						} else {
+							logger.warn("unsupported model adapter field data type: " + field.getType().getName());
+						}
+					} catch (SecurityException e) {
+						logger.warn("security error", e);
+					} catch (NoSuchFieldException e) {
+						logger.warn("no such field " + fieldName + " in " + className, e);
+					} catch (IllegalArgumentException e) {
+						throw new UnexpectedConditionError("代入する型はifでチェックしているハズ。", e);
+					} catch (IllegalAccessException e) {
+						throw new UnexpectedConditionError("setAccessible(true)したハズ。", e);
+					}
+				}
+				
+			} catch (ClassNotFoundException e) {
+				logger.warn("class not found (ignored): " + className, e);
+			}
+		}
+	}
+	
 }

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -18,16 +18,12 @@
  */
 package org.jiemamy.utils;
 
-import java.util.UUID;
-
 import javax.xml.namespace.QName;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.Validate;
-import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 
 import org.jiemamy.exception.UnexpectedConditionError;
 import org.jiemamy.xml.JiemamyQName;
@@ -40,47 +36,6 @@
 public final class DomUtil {
 	
 	/**
-	 * 要素の属性に設定された値を文字列として取得する。
-	 * 
-	 * @param domElement 要素
-	 * @param node 属性指定
-	 * @return 値
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static String getAttributeString(Element domElement, JiemamyQName node) {
-		Attr attr = XpathUtil.getAttr(domElement, "@" + node.getQNameString());
-		return attr.getValue();
-	}
-	
-	/**
-	 * 要素の属性に設定された値を{@link UUID}として取得する。
-	 * 
-	 * @param domNode ノード
-	 * @param node 属性指定
-	 * @return {@link UUID}
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static UUID getUUID(Node domNode, JiemamyQName node) {
-		Validate.notNull(node);
-		return getUUID(domNode, node.getQNameString());
-	}
-	
-	/**
-	 * 要素の属性に設定された値を{@link UUID}として取得する。
-	 * 
-	 * @param domNode ノード
-	 * @param attributeName 属性指定完全修飾名
-	 * @return {@link UUID}
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static UUID getUUID(Node domNode, String attributeName) {
-		Validate.notNull(attributeName);
-		
-		String uuidStr = XpathUtil.getAttr(domNode, "@" + attributeName).getValue();
-		return UUIDUtil.valueOfOrRandom(uuidStr);
-	}
-	
-	/**
 	 * XML要素が、指定された完全修飾名を持つ要素かどうかを調べる。
 	 * 
 	 * @param element 検査対象要素

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/SmartXpath.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/SmartXpath.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/SmartXpath.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/21
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy.utils;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.lang.Validate;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.jiemamy.Jiemamy;
+import org.jiemamy.exception.UnexpectedConditionError;
+import org.jiemamy.xml.JiemamyNamespaceContext;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class SmartXpath {
+	
+	/** XPathインスタンス */
+	public final XPath xpath = XPathFactory.newInstance().newXPath();
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param jiemamy
+	 */
+	public SmartXpath(Jiemamy jiemamy) {
+		xpath.setNamespaceContext(new JiemamyNamespaceContext(jiemamy.getNamespaces()));
+	}
+	
+	/**
+	 * XPath式で特定される{@link Attr}を取得する。
+	 * 
+	 * @param root 対象ノード
+	 * @param strExpr XPath式
+	 * @return 取得した {@link Attr}
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public Attr getAttr(Node root, String strExpr) {
+		Validate.notNull(root);
+		Validate.notNull(strExpr);
+		
+		try {
+			return (Attr) xpath.evaluate(strExpr, root, XPathConstants.NODE);
+		} catch (XPathExpressionException e) {
+			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
+		}
+	}
+	
+	/**
+	 * XPath式で特定される{@link Node}を取得する。
+	 * 
+	 * @param root 対象ノード
+	 * @param strExpr XPath式
+	 * @return 取得した {@link Node}
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public Node getNode(Node root, String strExpr) {
+		Validate.notNull(root);
+		Validate.notNull(strExpr);
+		
+		try {
+			return (Node) xpath.evaluate(strExpr, root, XPathConstants.NODE);
+		} catch (XPathExpressionException e) {
+			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
+		}
+	}
+	
+	/**
+	 * XPath式で特定される{@link NodeList}を取得する。
+	 * 
+	 * @param root 対象ノード
+	 * @param strExpr XPath式
+	 * @return 取得した {@link NodeList}
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public NodeList getNodes(Node root, String strExpr) {
+		Validate.notNull(root);
+		Validate.notNull(strExpr);
+		
+		try {
+			return (NodeList) xpath.evaluate(strExpr, root, XPathConstants.NODESET);
+		} catch (XPathExpressionException e) {
+			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
+		}
+	}
+	
+	/**
+	 * XPath式で特定されるノードの内容文字列を取得する。
+	 * 
+	 *<p> ノードが見つからなかった場合は{@code null}を返す。ノードはあるが空だった場合は空文字列を返す。</p>
+	 * 
+	 * @param root 対象ノード
+	 * @param strExpr XPath式
+	 * @return 取得した文字列
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public String getTextContent(Node root, String strExpr) {
+		Validate.notNull(root);
+		Validate.notNull(strExpr);
+		
+		try {
+			Node node = (Node) xpath.evaluate(strExpr, root, XPathConstants.NODE);
+			if (node == null) {
+				return null;
+			}
+			return node.getTextContent();
+		} catch (XPathExpressionException e) {
+			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
+		}
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/SmartXpath.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -1,134 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/01/29
- *
- * This file is part of Jiemamy.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-package org.jiemamy.utils;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.commons.lang.Validate;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.jiemamy.exception.UnexpectedConditionError;
-import org.jiemamy.xml.JiemamyNamespaceContext;
-
-/**
- * XPathを使用するユーティリティクラス。
- * 
- * @author daisuke
- */
-public final class XpathUtil {
-	
-	/** XPathインスタンス */
-	public static final XPath XPATH = XPathFactory.newInstance().newXPath();
-	
-	static {
-		XPATH.setNamespaceContext(new JiemamyNamespaceContext());
-	}
-	
-
-	/**
-	 * XPath式で特定される{@link Attr}を取得する。
-	 * 
-	 * @param root 対象ノード
-	 * @param strExpr XPath式
-	 * @return 取得した {@link Attr}
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static Attr getAttr(Node root, String strExpr) {
-		Validate.notNull(root);
-		Validate.notNull(strExpr);
-		
-		try {
-			return (Attr) XPATH.evaluate(strExpr, root, XPathConstants.NODE);
-		} catch (XPathExpressionException e) {
-			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
-		}
-	}
-	
-	/**
-	 * XPath式で特定される{@link Node}を取得する。
-	 * 
-	 * @param root 対象ノード
-	 * @param strExpr XPath式
-	 * @return 取得した {@link Node}
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static Node getNode(Node root, String strExpr) {
-		Validate.notNull(root);
-		Validate.notNull(strExpr);
-		
-		try {
-			return (Node) XPATH.evaluate(strExpr, root, XPathConstants.NODE);
-		} catch (XPathExpressionException e) {
-			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
-		}
-	}
-	
-	/**
-	 * XPath式で特定される{@link NodeList}を取得する。
-	 * 
-	 * @param root 対象ノード
-	 * @param strExpr XPath式
-	 * @return 取得した {@link NodeList}
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static NodeList getNodes(Node root, String strExpr) {
-		Validate.notNull(root);
-		Validate.notNull(strExpr);
-		
-		try {
-			return (NodeList) XPATH.evaluate(strExpr, root, XPathConstants.NODESET);
-		} catch (XPathExpressionException e) {
-			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
-		}
-	}
-	
-	/**
-	 * XPath式で特定されるノードの内容文字列を取得する。
-	 * 
-	 *<p> ノードが見つからなかった場合は{@code null}を返す。ノードはあるが空だった場合は空文字列を返す。</p>
-	 * 
-	 * @param root 対象ノード
-	 * @param strExpr XPath式
-	 * @return 取得した文字列
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public static String getTextContent(Node root, String strExpr) {
-		Validate.notNull(root);
-		Validate.notNull(strExpr);
-		
-		try {
-			Node node = (Node) XPATH.evaluate(strExpr, root, XPathConstants.NODE);
-			if (node == null) {
-				return null;
-			}
-			return node.getTextContent();
-		} catch (XPathExpressionException e) {
-			throw new UnexpectedConditionError("XPath expression error: " + strExpr, e);
-		}
-	}
-	
-	private XpathUtil() {
-	}
-	
-}

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -62,7 +62,7 @@
 		if (dataType instanceof DomainRef) {
 			DomainRef domainRef = (DomainRef) dataType;
 			DomainModel domainModel = resolver.resolve(domainRef);
-			builtin = (BuiltinDataType) domainModel.getDataType();
+			builtin = domainModel.getDataType();
 		} else if (dataType instanceof BuiltinDataType) {
 			builtin = (BuiltinDataType) dataType;
 		} else {

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/JiemamyNamespaceContext.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -23,6 +23,8 @@
 
 import javax.xml.namespace.NamespaceContext;
 
+import org.apache.commons.lang.Validate;
+
 /**
  * Jiemamy用の{@link NamespaceContext}実装クラス。
  * 
@@ -30,18 +32,32 @@
  */
 public class JiemamyNamespaceContext implements NamespaceContext {
 	
+	private JiemamyNamespace[] namespaces;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param namespaces
+	 * @throws IllegalArgumentException 引数namespaceが{@code null}または空の場合
+	 */
+	public JiemamyNamespaceContext(JiemamyNamespace[] namespaces) {
+		Validate.notEmpty(namespaces);
+		this.namespaces = namespaces.clone();
+	}
+	
 	public String getNamespaceURI(String prefix) {
-		for (JiemamyNamespace ns : CoreNamespace.values()) {
+		for (JiemamyNamespace ns : namespaces) {
 			if (prefix.equals(ns.getPrefix())) {
-				return ns.getNamespaceURI();
+				return ns.getNamespaceURI().toString();
 			}
 		}
 		return null;
 	}
 	
 	public String getPrefix(String namespaceURI) {
-		for (JiemamyNamespace ns : CoreNamespace.values()) {
-			if (namespaceURI.equals(ns.getNamespaceURI())) {
+		for (JiemamyNamespace ns : namespaces) {
+			if (namespaceURI.equals(ns.getNamespaceURI().toString())) {
 				return ns.getPrefix();
 			}
 		}

Copied: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/SmartXpathTest.java (from rev 3326, artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java)
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/SmartXpathTest.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/SmartXpathTest.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/03
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy.utils;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+
+import org.jiemamy.Jiemamy;
+
+/**
+ * {@link SmartXpath}のテストクラス。
+ * 
+ * @author daisuke
+ */
+public class SmartXpathTest {
+	
+	private static final String XML = //
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" //
+					+ "<root xmlns=\"http://jiemamy.org/xml/ns/core\" xmlns:view=\"http://jiemamy.org/xml/ns/view\">\n" //
+					+ "  <foobar id=\"1\">foo</foobar>\n" //
+					+ "  <foobar id=\"2\">bar</foobar>\n" //
+					+ "  <view:hogefuga id=\"3\">hoge</view:hogefuga>\n" //
+					+ "  <view:hogefuga id=\"4\">fuga</view:hogefuga>\n" //
+					+ "  <content id=\"5\">unba</content>\n" //
+					+ "  <empty1 id=\"5\"></empty1>\n" //
+					+ "  <empty2 id=\"6\"/>\n" //
+					+ "  <nil id=\"5\"><nullValue/></nil>\n" //
+					+ "</root>\n";
+	
+	private Document document;
+	
+	private SmartXpath smartXpath;
+	
+
+	/**
+	 * テストを初期化する。
+	 * 
+	 * @throws Exception 例外が発生した場合
+	 */
+	@Before
+	public void setUp() throws Exception {
+		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+		documentBuilderFactory.setNamespaceAware(true);
+		DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+		document = documentBuilder.parse(new ByteArrayInputStream(XML.getBytes("UTF-8")));
+		smartXpath = new SmartXpath(Jiemamy.newInstance());
+	}
+	
+	/**
+	 * テストの情報を破棄する。
+	 * 
+	 * @throws Exception 例外が発生した場合
+	 */
+	@After
+	public void tearDown() throws Exception {
+		document = null;
+		smartXpath = null;
+	}
+	
+	/**
+	 * デフォルトNamespaceのノードが取得できる。
+	 * 
+	 * @throws Exception 例外が発生した場合
+	 */
+	@Test
+	public void test01_デフォルトNamespaceの要素が取得できる() throws Exception {
+		assertThat(smartXpath.getNode(document, "/core:root"), is(notNullValue()));
+		assertThat(smartXpath.getNodes(document, "//core:foobar").getLength(), is(2));
+		assertThat(smartXpath.getNode(document, "/core:root/core:foobar[1]"), is(notNullValue()));
+		assertThat(smartXpath.getNode(document, "/core:root/core:foobar[2]"), is(notNullValue()));
+		assertThat(smartXpath.getNode(document, "/core:root/core:foobar[3]"), is(nullValue()));
+	}
+	
+	/**
+	 * 属性値が取得できる。
+	 * 
+	 * @throws Exception 例外が発生した場合
+	 */
+	@Test
+	public void test03_属性値が取得できる() throws Exception {
+		assertThat(smartXpath.getNode(document, "/core:root/core:foobar[1]/@id").getTextContent(), is("1"));
+		assertThat(smartXpath.getNode(document, "/core:root/core:foobar[2]/@id").getTextContent(), is("2"));
+	}
+	
+	/**
+	 * 要素の値が取得できる。
+	 * 
+	 * @throws Exception 例外が発生した場合
+	 */
+	@Test
+	public void test04_要素の値が取得できる() throws Exception {
+		assertThat(smartXpath.getTextContent(document, "/core:root/core:content"), is("unba"));
+		assertThat(smartXpath.getTextContent(document, "/core:root/core:empty1"), is(""));
+		assertThat(smartXpath.getTextContent(document, "/core:root/core:empty2"), is(""));
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/SmartXpathTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -1,132 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/02/03
- *
- * This file is part of Jiemamy.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
- */
-package org.jiemamy.utils;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.ByteArrayInputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.w3c.dom.Document;
-
-/**
- * {@link XpathUtil}のテストクラス。
- * 
- * @author daisuke
- */
-public class XpathUtilTest {
-	
-	private static final String XML = //
-			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" //
-					+ "<root xmlns=\"http://jiemamy.org/xml/ns/core\" xmlns:view=\"http://jiemamy.org/xml/ns/view\">\n" //
-					+ "  <foobar id=\"1\">foo</foobar>\n" //
-					+ "  <foobar id=\"2\">bar</foobar>\n" //
-					+ "  <view:hogefuga id=\"3\">hoge</view:hogefuga>\n" //
-					+ "  <view:hogefuga id=\"4\">fuga</view:hogefuga>\n" //
-					+ "  <content id=\"5\">unba</content>\n" //
-					+ "  <empty1 id=\"5\"></empty1>\n" //
-					+ "  <empty2 id=\"6\"/>\n" //
-					+ "  <nil id=\"5\"><nullValue/></nil>\n" //
-					+ "</root>\n";
-	
-	private Document document;
-	
-
-	/**
-	 * テストを初期化する。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Before
-	public void setUp() throws Exception {
-		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
-		documentBuilderFactory.setNamespaceAware(true);
-		DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
-		document = documentBuilder.parse(new ByteArrayInputStream(XML.getBytes("UTF-8")));
-	}
-	
-	/**
-	 * テストの情報を破棄する。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@After
-	public void tearDown() throws Exception {
-		document = null;
-	}
-	
-	/**
-	 * デフォルトNamespaceのノードが取得できる。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Test
-	public void test01_デフォルトNamespaceの要素が取得できる() throws Exception {
-		assertThat(XpathUtil.getNode(document, "/core:root"), is(notNullValue()));
-		assertThat(XpathUtil.getNodes(document, "//core:foobar").getLength(), is(2));
-		assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[1]"), is(notNullValue()));
-		assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[2]"), is(notNullValue()));
-		assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[3]"), is(nullValue()));
-	}
-	
-	/**
-	 * 特定Namespaceのノードが取得できる。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Test
-	public void test02_特定Namespaceのノードが要素できる() throws Exception {
-		assertThat(XpathUtil.getNodes(document, "//view:hogefuga").getLength(), is(2));
-		assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[1]"), is(notNullValue()));
-		assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[2]"), is(notNullValue()));
-		assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[3]"), is(nullValue()));
-	}
-	
-	/**
-	 * 属性値が取得できる。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Test
-	public void test03_属性値が取得できる() throws Exception {
-		assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[1]/@id").getTextContent(), is("1"));
-		assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[2]/@id").getTextContent(), is("2"));
-		assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[1]/@id").getTextContent(), is("3"));
-	}
-	
-	/**
-	 * 要素の値が取得できる。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Test
-	public void test04_要素の値が取得できる() throws Exception {
-		assertThat(XpathUtil.getTextContent(document, "/core:root/core:content"), is("unba"));
-		assertThat(XpathUtil.getTextContent(document, "/core:root/core:empty1"), is(""));
-		assertThat(XpathUtil.getTextContent(document, "/core:root/core:empty2"), is(""));
-	}
-}

Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -21,10 +21,12 @@
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
-import org.junit.After;
-import org.junit.Before;
+import javax.xml.namespace.NamespaceContext;
+
 import org.junit.Test;
 
+import org.jiemamy.Jiemamy;
+
 /**
  * {@link JiemamyNamespaceContext}のテストクラス。
  * 
@@ -32,42 +34,19 @@
  */
 public class JiemamyNamespaceContextTest {
 	
-	private JiemamyNamespaceContext ctx;
-	
-
 	/**
-	 * テストを初期化する。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Before
-	public void setUp() throws Exception {
-		ctx = new JiemamyNamespaceContext();
-	}
-	
-	/**
-	 * テストの情報を破棄する。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@After
-	public void tearDown() throws Exception {
-		ctx = null;
-	}
-	
-	/**
 	 * prefixからURIが、URIからprefixが相互変換できる。
 	 * 
 	 * @throws Exception 例外が発生した場合
 	 */
 	@Test
 	public void test01_prefixからURIが_URIからprefixが相互変換できる() throws Exception {
+		NamespaceContext ctx = new JiemamyNamespaceContext(Jiemamy.newInstance().getNamespaces());
 		assertThat(ctx.getNamespaceURI(""), is("http://jiemamy.org/xml/ns/core"));
 		assertThat(ctx.getNamespaceURI("core"), is("http://jiemamy.org/xml/ns/core"));
 		assertThat(ctx.getPrefix("http://jiemamy.org/xml/ns/core"), is(""));
 		
-		assertThat(ctx.getNamespaceURI("view"), is("http://jiemamy.org/xml/ns/view"));
-		assertThat(ctx.getPrefix("http://jiemamy.org/xml/ns/view"), is("view"));
-		
+//		assertThat(ctx.getNamespaceURI("view"), is("http://jiemamy.org/xml/ns/view"));
+//		assertThat(ctx.getPrefix("http://jiemamy.org/xml/ns/view"), is("view"));
 	}
 }

Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ArtemisView.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ArtemisView.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ArtemisView.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -30,6 +30,8 @@
 import org.jiemamy.internal.enhance.ViewFactoryExtensionEnhancer;
 import org.jiemamy.utils.CollectionsUtil;
 import org.jiemamy.utils.enhancer.Enhance;
+import org.jiemamy.xml.JiemamyNamespace;
+import org.jiemamy.xml.ViewNamespace;
 
 /**
  * Jiemamy {@link Artemis} Implementationに対する、Jiemamy View Specification拡張クラス。
@@ -49,6 +51,10 @@
 		return enhances;
 	}
 	
+	public JiemamyNamespace[] getNamespaces() {
+		return ViewNamespace.values();
+	}
+	
 	public Set<? extends OptionalSpec> getSpecs() {
 		return EnumSet.of(OfficialSpecs.VIEW);
 	}

Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewDomSerializerEnhancer.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewDomSerializerEnhancer.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewDomSerializerEnhancer.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -21,6 +21,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.Validate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Attr;
@@ -50,11 +51,14 @@
 import org.jiemamy.utils.DomUtil;
 import org.jiemamy.utils.IterableNodeList;
 import org.jiemamy.utils.LogMarker;
-import org.jiemamy.utils.XpathUtil;
+import org.jiemamy.utils.SmartXpath;
+import org.jiemamy.utils.UUIDUtil;
 import org.jiemamy.utils.enhancer.Invocation;
 import org.jiemamy.utils.enhancer.InvocationHandler;
 import org.jiemamy.utils.model.RootModelUtil;
 import org.jiemamy.xml.CoreQName;
+import org.jiemamy.xml.JiemamyQName;
+import org.jiemamy.xml.ViewNamespace;
 import org.jiemamy.xml.ViewQName;
 
 /**
@@ -82,6 +86,8 @@
 		
 		private Jiemamy jiemamy;
 		
+		private SmartXpath smartXpath;
+		
 
 		/**
 		 * インスタンスを生成する。
@@ -92,6 +98,7 @@
 		public JiemamyViewDomSerializer(Jiemamy jiemamy) {
 			super(jiemamy);
 			this.jiemamy = jiemamy;
+			smartXpath = new SmartXpath(jiemamy);
 			logger.info(LogMarker.LIFECYCLE, "JiemamyDomSerializer extended by Jiemamy VIEW Specification");
 		}
 		
@@ -105,9 +112,13 @@
 			}
 			
 			Element rootElement = document.getDocumentElement();
-			// FIXME locationを正式なURLに
-			rootElement.setAttribute("xsi:schemaLocation", rootElement.getAttribute("xsi:schemaLocation")
-					+ " http://jiemamy.org/xml/ns/view ../../main/resources/jiemamy-view.xsd");
+			StringBuilder sb = new StringBuilder();
+			sb.append(rootElement.getAttribute("xsi:schemaLocation"));
+			sb.append(" ");
+			sb.append(ViewNamespace.NS_VIEW.getNamespaceURI().toString());
+			sb.append(" ");
+			sb.append(ViewNamespace.NS_VIEW.getXmlSchemaLocation());
+			rootElement.setAttribute("xsi:schemaLocation", sb.toString());
 			
 			Element diagramPresentationsElement =
 					DomUtil.newChild(document.getDocumentElement(), ViewQName.DIAGRAM_PRESENTATIONS);
@@ -196,7 +207,7 @@
 		protected RootModel toRootModel(Document document) throws SerializationException {
 			RootModel rootModel = super.toRootModel(document);
 			NodeList dpNodeList =
-					XpathUtil.getNodes(document, "/core:jiemamy/view:diagramPresentations/view:diagramPresentation");
+					smartXpath.getNodes(document, "/core:jiemamy/view:diagramPresentations/view:diagramPresentation");
 			Iterable<Node> dpNodeListIterable = new IterableNodeList(dpNodeList);
 			logger.debug("presentation count = " + dpNodeList.getLength());
 			
@@ -208,15 +219,15 @@
 				}
 				Element dpElement = (Element) dpNode;
 				DiagramPresentationModel presentation =
-						factory.newModel(DiagramPresentationModel.class, DomUtil.getUUID(dpElement, CoreQName.ID));
-				presentation.setName(XpathUtil.getTextContent(dpElement, "core:name"));
+						factory.newModel(DiagramPresentationModel.class, getUUID(dpElement, CoreQName.ID));
+				presentation.setName(smartXpath.getTextContent(dpElement, "core:name"));
 				
-				String modeString = XpathUtil.getTextContent(dpElement, "view:mode");
+				String modeString = smartXpath.getTextContent(dpElement, "view:mode");
 				if (StringUtils.isEmpty(modeString) == false) {
 					presentation.setMode(Mode.valueOf(modeString));
 				}
 				
-				String levelString = XpathUtil.getTextContent(dpElement, "view:level");
+				String levelString = smartXpath.getTextContent(dpElement, "view:level");
 				if (StringUtils.isEmpty(levelString) == false) {
 					presentation.setLevel(Level.valueOf(levelString));
 				}
@@ -229,17 +240,32 @@
 			return rootModel;
 		}
 		
+		/**
+		 * 要素の属性に設定された値を{@link UUID}として取得する。
+		 * 
+		 * @param domNode ノード
+		 * @param node 属性指定
+		 * @return {@link UUID}
+		 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+		 */
+		private UUID getUUID(Node domNode, JiemamyQName node) {
+			Validate.notNull(node);
+			
+			String uuidStr = smartXpath.getAttr(domNode, "@" + node.getQNameString()).getValue();
+			return UUIDUtil.valueOfOrRandom(uuidStr);
+		}
+		
 		private void processConnectionProfile(JiemamyFactory factory, DiagramPresentationModel presentation,
 				Element dpElement) {
 			RootModel rootModel = factory.getRootModel();
 			NodeList connectionProfileNodeList =
-					XpathUtil.getNodes(dpElement, "view:connectionProfiles/view:connectionProfile");
+					smartXpath.getNodes(dpElement, "view:connectionProfiles/view:connectionProfile");
 			Iterable<Node> connectionProfileNodeListIterable = new IterableNodeList(connectionProfileNodeList);
 			for (Node connectionProfileNode : connectionProfileNodeListIterable) {
 				ConnectionAdapter connectionAdapter;
-				Node objectRefNode = XpathUtil.getNode(connectionProfileNode, "view:connectionObjectRef");
+				Node objectRefNode = smartXpath.getNode(connectionProfileNode, "view:connectionObjectRef");
 				if (objectRefNode != null) {
-					UUID refId = DomUtil.getUUID(objectRefNode, CoreQName.REF);
+					UUID refId = getUUID(objectRefNode, CoreQName.REF);
 					JiemamyElement jElement = RootModelUtil.findJiemamyElement(rootModel, refId);
 					if (jElement == null) {
 						logger.error("null element: " + refId.toString());
@@ -254,14 +280,14 @@
 					continue;
 				}
 				ConnectionProfile connectionProfile =
-						factory.newModel(ConnectionProfile.class, DomUtil.getUUID(connectionProfileNode, CoreQName.ID));
+						factory.newModel(ConnectionProfile.class, getUUID(connectionProfileNode, CoreQName.ID));
 				
 				NodeList bendpointNodeList =
-						XpathUtil.getNodes(connectionProfileNode, "view:bendpoints/view:bendpoint");
+						smartXpath.getNodes(connectionProfileNode, "view:bendpoints/view:bendpoint");
 				Iterable<Node> bendpointNodeListIterable = new IterableNodeList(bendpointNodeList);
 				for (Node bendpointNode : bendpointNodeListIterable) {
-					int x = Integer.valueOf(XpathUtil.getAttr(bendpointNode, "@x").getValue());
-					int y = Integer.valueOf(XpathUtil.getAttr(bendpointNode, "@y").getValue());
+					int x = Integer.valueOf(smartXpath.getAttr(bendpointNode, "@x").getValue());
+					int y = Integer.valueOf(smartXpath.getAttr(bendpointNode, "@y").getValue());
 					connectionProfile.getBendpoints().add(new JmPoint(x, y));
 				}
 				presentation.getConnectionProfiles().put(connectionAdapter, connectionProfile);
@@ -270,13 +296,13 @@
 		
 		private void processNodeProfile(JiemamyFactory factory, DiagramPresentationModel presentation, Element dpElement) {
 			RootModel rootModel = factory.getRootModel();
-			NodeList nodeProfileNodeList = XpathUtil.getNodes(dpElement, "view:nodeProfiles/view:nodeProfile");
+			NodeList nodeProfileNodeList = smartXpath.getNodes(dpElement, "view:nodeProfiles/view:nodeProfile");
 			Iterable<Node> nodeProfileNodeListIterable = new IterableNodeList(nodeProfileNodeList);
 			for (Node nodeProfileNode : nodeProfileNodeListIterable) {
 				NodeAdapter nodeAdapter;
-				Node objectRefNode = XpathUtil.getNode(nodeProfileNode, "view:nodeObjectRef");
+				Node objectRefNode = smartXpath.getNode(nodeProfileNode, "view:nodeObjectRef");
 				if (objectRefNode != null) {
-					UUID refId = DomUtil.getUUID(objectRefNode, CoreQName.REF);
+					UUID refId = getUUID(objectRefNode, CoreQName.REF);
 					JiemamyElement jElement = RootModelUtil.findJiemamyElement(rootModel, refId);
 					if (jElement == null) {
 						logger.error("null element: " + refId.toString());
@@ -288,27 +314,25 @@
 						continue;
 					}
 				} else {
-					Node stickytNode = XpathUtil.getNode(nodeProfileNode, "view:sticky");
-					StickyModel stickyModel =
-							factory.newModel(StickyModel.class, DomUtil.getUUID(stickytNode, CoreQName.ID));
-					stickyModel.setContents(XpathUtil.getTextContent(stickytNode, "view:contents"));
+					Node stickytNode = smartXpath.getNode(nodeProfileNode, "view:sticky");
+					StickyModel stickyModel = factory.newModel(StickyModel.class, getUUID(stickytNode, CoreQName.ID));
+					stickyModel.setContents(smartXpath.getTextContent(stickytNode, "view:contents"));
 					nodeAdapter = stickyModel;
 				}
-				int x = Integer.valueOf(XpathUtil.getAttr(nodeProfileNode, "view:boundary/@x").getValue());
-				int y = Integer.valueOf(XpathUtil.getAttr(nodeProfileNode, "view:boundary/@y").getValue());
-				int width = Integer.valueOf(XpathUtil.getAttr(nodeProfileNode, "view:boundary/@width").getValue());
-				int height = Integer.valueOf(XpathUtil.getAttr(nodeProfileNode, "view:boundary/@height").getValue());
+				int x = Integer.valueOf(smartXpath.getAttr(nodeProfileNode, "view:boundary/@x").getValue());
+				int y = Integer.valueOf(smartXpath.getAttr(nodeProfileNode, "view:boundary/@y").getValue());
+				int width = Integer.valueOf(smartXpath.getAttr(nodeProfileNode, "view:boundary/@width").getValue());
+				int height = Integer.valueOf(smartXpath.getAttr(nodeProfileNode, "view:boundary/@height").getValue());
 				
-				Attr colorAttr = XpathUtil.getAttr(nodeProfileNode, "view:boundary/@color");
+				Attr colorAttr = smartXpath.getAttr(nodeProfileNode, "view:boundary/@color");
 				JmColor color = colorAttr == null ? null : JmColor.parse(colorAttr.getValue());
 				
-				NodeProfile nodeProfile =
-						factory.newModel(NodeProfile.class, DomUtil.getUUID(nodeProfileNode, CoreQName.ID));
+				NodeProfile nodeProfile = factory.newModel(NodeProfile.class, getUUID(nodeProfileNode, CoreQName.ID));
 				nodeProfile.setBoundary(new JmRectangle(x, y, width, height));
 				nodeProfile.setColor(color);
 				presentation.getNodeProfiles().put(nodeAdapter, nodeProfile);
 			}
-			presentation.setName(XpathUtil.getTextContent(dpElement, "core:name"));
+			presentation.setName(smartXpath.getTextContent(dpElement, "core:name"));
 		}
 	}
 }

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -31,6 +31,7 @@
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.sql.SqlStatement;
 import org.jiemamy.serializer.JiemamySerializer;
+import org.jiemamy.xml.JiemamyNamespace;
 
 /**
  * Jiemamyのコントロール中枢クラス。
@@ -258,6 +259,16 @@
 	}
 	
 	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 * @since 0.2
+	 */
+	public JiemamyNamespace[] getNamespaces() {
+		return defaultImplementation.getNamespaces();
+	}
+	
+	/**
 	 * 参照リゾルバを取得する。
 	 * 
 	 * @return 参照リゾルバ

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyImplementation.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -22,6 +22,7 @@
 
 import org.jiemamy.facade.JiemamyFacade;
 import org.jiemamy.serializer.JiemamySerializer;
+import org.jiemamy.xml.JiemamyNamespace;
 
 /**
  * Jiemamy実装(及び仕様範囲)を表すインターフェイス。
@@ -59,6 +60,14 @@
 	JiemamyFactory getFactory(Jiemamy jiemamy);
 	
 	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 * @since 0.2
+	 */
+	JiemamyNamespace[] getNamespaces();
+	
+	/**
 	 * 参照リゾルバを取得する。
 	 * 
 	 * <p>{@code null}を返してはならない。</p>

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreNamespace.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreNamespace.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreNamespace.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -18,11 +18,14 @@
  */
 package org.jiemamy.xml;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jiemamy.exception.UnexpectedConditionError;
+
 /**
  * XML名前空間定数クラス。
  * 
- * TODO VIEWとかDIFFがCOREにいるので排除
- * 
  * @since 0.2
  * @author daisuke
  */
@@ -38,14 +41,10 @@
 	NS_XSI("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
 
 	/** Jiemamy core specifications */
-	NS_CORE("", "http://jiemamy.org/xml/ns/core"),
+	NS_CORE("", "http://jiemamy.org/xml/ns/core", "http://jiemamy.org/xml/0.2.0/jiemamy-core.xsd"),
 
-	/** Jiemamy view specifications */
-	@Deprecated
-	NS_VIEW("view", "http://jiemamy.org/xml/ns/view"),
-
 	/** Jiemamy core specifications */
-	NS_DEFAULT("core", "http://jiemamy.org/xml/ns/core"),
+	NS_DEFAULT("core", "http://jiemamy.org/xml/ns/core", "http://jiemamy.org/xml/0.2.0/jiemamy-core.xsd"),
 
 	/**  */
 	NONE("", "");
@@ -54,19 +53,34 @@
 	private final String prefix;
 	
 	/** 名前空間URL */
-	private final String namespaceURI;
+	private final URI namespaceURI;
 	
+	private final String xmlSchemaLocation;
+	
 
 	CoreNamespace(String prefix, String namespaceURI) {
+		this(prefix, namespaceURI, null);
+	}
+	
+	CoreNamespace(String prefix, String namespaceURI, String xmlSchemaLocation) {
 		this.prefix = prefix;
-		this.namespaceURI = namespaceURI;
+		try {
+			this.namespaceURI = new URI(namespaceURI);
+			this.xmlSchemaLocation = xmlSchemaLocation;
+		} catch (URISyntaxException e) {
+			throw new UnexpectedConditionError("URI記述ミス?", e);
+		}
 	}
 	
-	public String getNamespaceURI() {
+	public URI getNamespaceURI() {
 		return namespaceURI;
 	}
 	
 	public String getPrefix() {
 		return prefix;
 	}
+	
+	public String getXmlSchemaLocation() {
+		return xmlSchemaLocation;
+	}
 }

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/CoreQName.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -213,7 +213,7 @@
 	
 
 	CoreQName(JiemamyNamespace namespace, String localPart) {
-		qName = new QName(namespace.getNamespaceURI(), localPart, namespace.getPrefix());
+		qName = new QName(namespace.getNamespaceURI().toString(), localPart, namespace.getPrefix());
 	}
 	
 	public QName getQName() {

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/xml/JiemamyNamespace.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.xml;
 
+import java.net.URI;
+
 /**
  * Jiemamyで使用するXML名前空間を表すインターフェイス。
  * 
@@ -31,7 +33,7 @@
 	 * @return 名前空間URI
 	 * @since 0.2
 	 */
-	String getNamespaceURI();
+	URI getNamespaceURI();
 	
 	/**
 	 * 名前空間prefixを取得する。
@@ -41,4 +43,11 @@
 	 */
 	String getPrefix();
 	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return XMLスキーマのURL. may be null.
+	 * @since 0.2
+	 */
+	String getXmlSchemaLocation();
 }

Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml	2009-04-21 12:13:44 UTC (rev 3332)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jiemamy xmlns="http://jiemamy.org/xml/ns/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="d5a96af3-b1e9-4285-a8ef-c491ce5ae308" xsi:schemaLocation="http://jiemamy.org/xml/ns/core ../../main/resources/jiemamy-core.xsd http://jiemamy.org/xml/ns/view ../../main/resources/jiemamy-view.xsd" version="0.2-SNAPSHOT">
+<jiemamy xmlns="http://jiemamy.org/xml/ns/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="d5a96af3-b1e9-4285-a8ef-c491ce5ae308" xsi:schemaLocation="http://jiemamy.org/xml/ns/core http://jiemamy.org/xml/0.2.0/jiemamy-core.xsd http://jiemamy.org/xml/ns/view http://jiemamy.org/xml/0.2.0/jiemamy-view.xsd" version="0.2-SNAPSHOT">
   <dialect>org.jiemamy.dialect.mysql.MySqlDialect</dialect>
   <schemaName>FOO</schemaName>
   <description>Jiemamyテストモデル1</description>

Modified: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewNamespace.java
===================================================================
--- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewNamespace.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewNamespace.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -18,6 +18,11 @@
  */
 package org.jiemamy.xml;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jiemamy.exception.UnexpectedConditionError;
+
 /**
  * XML名前空間定数クラス。
  * 
@@ -35,20 +40,35 @@
 	/** 名前空間prefix */
 	private final String prefix;
 	
-	/** 名前空間URL */
-	private final String namespaceURI;
+	/** 名前空間URI */
+	private final URI namespaceURI;
 	
+	private final String xmlSchemaLocation;
+	
 
 	ViewNamespace(String prefix, String namespaceURI) {
+		this(prefix, namespaceURI, null);
+	}
+	
+	ViewNamespace(String prefix, String namespaceURI, String xmlSchemaLocation) {
 		this.prefix = prefix;
-		this.namespaceURI = namespaceURI;
+		try {
+			this.namespaceURI = new URI(namespaceURI);
+			this.xmlSchemaLocation = xmlSchemaLocation;
+		} catch (URISyntaxException e) {
+			throw new UnexpectedConditionError("URI記述ミス?", e);
+		}
 	}
 	
-	public String getNamespaceURI() {
+	public URI getNamespaceURI() {
 		return namespaceURI;
 	}
 	
 	public String getPrefix() {
 		return prefix;
 	}
+	
+	public String getXmlSchemaLocation() {
+		return xmlSchemaLocation;
+	}
 }

Modified: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java
===================================================================
--- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java	2009-04-21 01:54:15 UTC (rev 3331)
+++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java	2009-04-21 12:13:44 UTC (rev 3332)
@@ -78,7 +78,7 @@
 	
 
 	ViewQName(JiemamyNamespace namespace, String localPart) {
-		qName = new QName(namespace.getNamespaceURI(), localPart, namespace.getPrefix());
+		qName = new QName(namespace.getNamespaceURI().toString(), localPart, namespace.getPrefix());
 	}
 	
 	public QName getQName() {



Jiemamy-notify メーリングリストの案内
Zurück zum Archiv-Index