[prev in list] [next in list] [prev in thread] [next in thread]
List: openmrs-svn
Subject: [29962] openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x compatible: Added new XML utility metho
From: svn-noreply () openmrs ! org
Date: 2013-03-29 19:31:13
Message-ID: 20130329193113.7C1A9402D3 () openmrs ! osuosl ! org
[Download RAW message or body]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29962] openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x compatible: Added \
new XML utility methods for Document processing.</title> </head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>29962</dd>
<dt>Author</dt> <dd>sjmckee</dd>
<dt>Date</dt> <dd>2013-03-29 19:31:13 +0000 (Fri, 29 Mar 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Added new XML utility methods for Document processing.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#openmrsmoduleschirdlutilbrancheschirdlutil17xcompatiblemetadataconfigxml">openmrs-modules/chirdlutil/branches/chirdlutil \
1.7.x compatible/metadata/config.xml</a></li> <li><a \
href="#openmrsmoduleschirdlutilbrancheschirdlutil17xcompatiblesrcorgopenmrsmodulechirdlutilutilXMLUtiljava">openmrs-modules/chirdlutil/branches/chirdlutil \
1.7.x compatible/src/org/openmrs/module/chirdlutil/util/XMLUtil.java</a></li> </ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#openmrsmoduleschirdlutilbrancheschirdlutil17xcompatiblesrcorgopenmrsmodulechirdlutilutilXMLTagNamejava">openmrs-modules/chirdlutil/branches/chirdlutil \
1.7.x compatible/src/org/openmrs/module/chirdlutil/util/XMLTagName.java</a></li> \
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="openmrsmoduleschirdlutilbrancheschirdlutil17xcompatiblemetadataconfigxml"></a>
<div class="modfile"><h4>Modified: openmrs-modules/chirdlutil/branches/chirdlutil \
1.7.x compatible/metadata/config.xml (29961 => 29962)</h4> <pre class="diff"><span>
<span class="info">--- openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/metadata/config.xml 2013-03-29 19:26:16 UTC (rev 29961)
+++ openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/metadata/config.xml 2013-03-29 19:31:13 UTC (rev 29962) </span><span \
class="lines">@@ -6,7 +6,7 @@ </span><span class="cx"> <!-- chirdlutil Module \
Properties --> </span><span class="cx"> <id>chirdlutil</id>
</span><span class="cx"> <name>chirdlutil</name>
</span><del>- <version>1.0.28</version>
</del><ins>+ <version>1.1.0</version>
</ins><span class="cx"> \
<package>org.openmrs.module.@MODULE_ID@</package> </span><span \
class="cx"> <author>Tammy Dugan</author> </span><span class="cx"> \
<description> </span></span></pre></div>
<a id="openmrsmoduleschirdlutilbrancheschirdlutil17xcompatiblesrcorgopenmrsmodulechirdlutilutilXMLTagNamejava"></a>
<div class="addfile"><h4>Added: openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/src/org/openmrs/module/chirdlutil/util/XMLTagName.java (0 => 29962)</h4> \
<pre class="diff"><span> <span class="info">--- \
openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/src/org/openmrs/module/chirdlutil/util/XMLTagName.java \
(rev 0)
+++ openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/src/org/openmrs/module/chirdlutil/util/XMLTagName.java 2013-03-29 19:31:13 \
UTC (rev 29962) </span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/**
+ * The contents of this file are subject to the OpenMRS Public License
+ * Version 1.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://license.openmrs.org
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * Copyright (C) OpenMRS, LLC. All Rights Reserved.
+ */
+package org.openmrs.module.chirdlutil.util;
+
+
+/**
+ * Constants class for XML tags names.
+ *
+ * @author Steve McKee
+ */
+public class XMLTagName {
+
+ public static final String CCD_RECORD_TARGET = "recordTarget";
+ public static final String CCD_PATIENT_ROLE = "patientRole";
+ public static final String CCD_PATIENT = "patient";
+ public static final String CCD_ADMIN_GENDER_CODE = \
"administrativeGenderCode"; + public static final String CCD_CODE = \
"code"; + public static final String CCD_BIRTH_TIME = \
"birthTime"; + public static final String CCD_VALUE = "value";
+ public static final String CCD_NAME = "name";
+ public static final String CCD_FAMILY_NAME = "family";
+ public static final String CCD_GIVEN_NAME = "given";
+ public static final String CCD_ADDRESS = "addr";
+ public static final String CCD_STREET_ADDRESS = "streetAddressLine";
+ public static final String CCD_CITY = "city";
+ public static final String CCD_STATE = "state";
+ public static final String CCD_POSTAL_CODE = "postalCode";
+ public static final String CCD_ID = "id";
+ public static final String CCD_EXTENSION = "extension";
+ public static final String CCD_RACE_CODE = "raceCode";
+ public static final String CCD_MARITAL_STATUS_CODE = "maritalStatusCode";
+ public static final String CCD_TRANSLATION = "translation";
+ public static final String CCD_TELECOM = "telecom";
+}
</ins></span></pre></div>
<a id="openmrsmoduleschirdlutilbrancheschirdlutil17xcompatiblesrcorgopenmrsmodulechirdlutilutilXMLUtiljava"></a>
<div class="modfile"><h4>Modified: openmrs-modules/chirdlutil/branches/chirdlutil \
1.7.x compatible/src/org/openmrs/module/chirdlutil/util/XMLUtil.java (29961 => \
29962)</h4> <pre class="diff"><span>
<span class="info">--- openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/src/org/openmrs/module/chirdlutil/util/XMLUtil.java 2013-03-29 19:26:16 \
UTC (rev 29961)
+++ openmrs-modules/chirdlutil/branches/chirdlutil 1.7.x \
compatible/src/org/openmrs/module/chirdlutil/util/XMLUtil.java 2013-03-29 19:31:13 \
UTC (rev 29962) </span><span class="lines">@@ -5,8 +5,10 @@
</span><span class="cx"> import java.io.IOException;
</span><span class="cx"> import java.io.InputStream;
</span><span class="cx"> import java.io.OutputStream;
</span><ins>+import java.util.ArrayList;
</ins><span class="cx"> import java.util.HashMap;
</span><span class="cx"> import java.util.Iterator;
</span><ins>+import java.util.List;
</ins><span class="cx">
</span><span class="cx"> import javax.xml.parsers.DocumentBuilder;
</span><span class="cx"> import javax.xml.parsers.DocumentBuilderFactory;
</span><span class="lines">@@ -27,6 +29,8 @@
</span><span class="cx"> import org.jibx.runtime.IUnmarshallingContext;
</span><span class="cx"> import org.w3c.dom.Document;
</span><span class="cx"> import org.w3c.dom.Element;
</span><ins>+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Contains several utility methods to aide in XML \
processing. </span><span class="lines">@@ -245,4 +249,70 @@
</span><span class="cx"> throw new IOException("Error parsing xml input \
stream."); </span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
+ /**
+ * Returns a node's child node by tag name.
+ *
+ * @param parentNode The node containing the child node.
+ * @param tagName The tag name of the child node.
+ * @return Node of the parent node or null if a child with the tag name cannot be \
found. + */
+ public static Node getChildNode(Node parentNode, String tagName) {
+ NodeList nodes = parentNode.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ if (tagName.equals(node.getNodeName())) {
+ return node;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns a list of child nodes by tag name.
+ *
+ * @param parentNode The node containing the child nodes.
+ * @param tagName The tag name of the child nodes.
+ * @return List of Node objects of the parent node.
+ */
+ public static List<Node> getChildNodes(Node parentNode, String tagName) {
+ NodeList nodes = parentNode.getChildNodes();
+ List<Node> finalNodes = new ArrayList<Node>();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ if (tagName.equals(node.getNodeName())) {
+ finalNodes.add(node);
+ }
+ }
+
+ return finalNodes;
+ }
+
+ /**
+ * Returns an attribute value for a node.
+ *
+ * @param node The node containing the attribute.
+ * @param attributeName The name of the attribute used to find the value.
+ * @return The value of the attribute or null if the attribute cannot be found.
+ */
+ public static String getAttributeValue(Node node, String attributeName) {
+ return ((Element)node).getAttribute(attributeName);
+ }
+
+ /**
+ * Returns the value of a node's child node.
+ *
+ * @param parentNode The node containing the data to find.
+ * @param childTagName The tag name of the child node.
+ * @return The value of a child or null if the child not cannot be found or doesn't \
contain a value. + */
+ public static String getChildNodeValue(Node parentNode, String childTagName) {
+ Node childNode = XMLUtil.getChildNode(parentNode, childTagName);
+ if (childNode != null) {
+ return childNode.getTextContent();
+ }
+
+ return null;
+ }
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>
<p></p>
-- <br />
-- OpenMRS Subversion Commits: <a \
href="http://go.openmrs.org/svn">http://go.openmrs.org/svn</a><br /> Posting is not \
allowed - please join dev@openmrs.org for discussion.<br />
Unsubscribe: svn+unsubscribe@openmrs.org<br />
<br />
<br />
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic