Publish 2.2

This commit is contained in:
James 2016-12-20 19:00:37 -05:00
parent c1cc4802f3
commit 0ec61533a8
64 changed files with 6891 additions and 6892 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -18,37 +18,37 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-client-okhttp</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jaxrsserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
@ -59,7 +59,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jaxrsserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -29,7 +29,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
@ -40,25 +40,25 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-client-okhttp</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</parent>
<packaging>jar</packaging>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -41,7 +41,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>woodstox-core-asl</artifactId>
@ -56,7 +56,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>woodstox-core-asl</artifactId>
@ -67,7 +67,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>woodstox-core-asl</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -59,7 +59,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>woodstox-core-asl</artifactId>
@ -74,7 +74,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>woodstox-core-asl</artifactId>
@ -85,7 +85,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>woodstox-core-asl</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -20,23 +20,23 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class DefinitionException extends FHIRException {
public DefinitionException() {
super();
}
public DefinitionException(String message, Throwable cause) {
super(message, cause);
}
public DefinitionException(String message) {
super(message);
}
public DefinitionException(Throwable cause) {
super(cause);
}
}
public class DefinitionException extends FHIRException {
public DefinitionException() {
super();
}
public DefinitionException(String message, Throwable cause) {
super(message, cause);
}
public DefinitionException(String message) {
super(message);
}
public DefinitionException(Throwable cause) {
super(cause);
}
}

View File

@ -20,25 +20,25 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class FHIRException extends Exception {
// Note that the 4-argument constructor has been removed as it is not JDK6 compatible
public FHIRException() {
super();
}
public FHIRException(String message, Throwable cause) {
super(message, cause);
}
public FHIRException(String message) {
super(message);
}
public FHIRException(Throwable cause) {
super(cause);
}
}
public class FHIRException extends Exception {
// Note that the 4-argument constructor has been removed as it is not JDK6 compatible
public FHIRException() {
super();
}
public FHIRException(String message, Throwable cause) {
super(message, cause);
}
public FHIRException(String message) {
super(message);
}
public FHIRException(Throwable cause) {
super(cause);
}
}

View File

@ -20,25 +20,25 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class FHIRFormatError extends FHIRException {
private static final long serialVersionUID = 1L;
public FHIRFormatError() {
super();
}
public FHIRFormatError(String message, Throwable cause) {
super(message, cause);
}
public FHIRFormatError(String message) {
super(message);
}
public FHIRFormatError(Throwable cause) {
super(cause);
}
}
public class FHIRFormatError extends FHIRException {
private static final long serialVersionUID = 1L;
public FHIRFormatError() {
super();
}
public FHIRFormatError(String message, Throwable cause) {
super(message, cause);
}
public FHIRFormatError(String message) {
super(message);
}
public FHIRFormatError(Throwable cause) {
super(cause);
}
}

View File

@ -20,23 +20,23 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class NoTerminologyServiceException extends FHIRException {
public NoTerminologyServiceException() {
super();
}
public NoTerminologyServiceException(String message, Throwable cause) {
super(message, cause);
}
public NoTerminologyServiceException(String message) {
super(message);
}
public NoTerminologyServiceException(Throwable cause) {
super(cause);
}
}
public class NoTerminologyServiceException extends FHIRException {
public NoTerminologyServiceException() {
super();
}
public NoTerminologyServiceException(String message, Throwable cause) {
super(message, cause);
}
public NoTerminologyServiceException(String message) {
super(message);
}
public NoTerminologyServiceException(Throwable cause) {
super(cause);
}
}

View File

@ -20,23 +20,23 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class PathEngineException extends FHIRException {
public PathEngineException() {
super();
}
public PathEngineException(String message, Throwable cause) {
super(message, cause);
}
public PathEngineException(String message) {
super(message);
}
public PathEngineException(Throwable cause) {
super(cause);
}
}
public class PathEngineException extends FHIRException {
public PathEngineException() {
super();
}
public PathEngineException(String message, Throwable cause) {
super(message, cause);
}
public PathEngineException(String message) {
super(message);
}
public PathEngineException(Throwable cause) {
super(cause);
}
}

View File

@ -20,23 +20,23 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class TerminologyServiceException extends FHIRException {
public TerminologyServiceException() {
super();
}
public TerminologyServiceException(String message, Throwable cause) {
super(message, cause);
}
public TerminologyServiceException(String message) {
super(message);
}
public TerminologyServiceException(Throwable cause) {
super(cause);
}
}
public class TerminologyServiceException extends FHIRException {
public TerminologyServiceException() {
super();
}
public TerminologyServiceException(String message, Throwable cause) {
super(message, cause);
}
public TerminologyServiceException(String message) {
super(message);
}
public TerminologyServiceException(Throwable cause) {
super(cause);
}
}

View File

@ -20,23 +20,23 @@ package org.hl7.fhir.exceptions;
* #L%
*/
public class UcumException extends FHIRException {
public UcumException() {
super();
}
public UcumException(String message, Throwable cause) {
super(message, cause);
}
public UcumException(String message) {
super(message);
}
public UcumException(Throwable cause) {
super(cause);
}
}
public class UcumException extends FHIRException {
public UcumException() {
super();
}
public UcumException(String message, Throwable cause) {
super(message, cause);
}
public UcumException(String message) {
super(message);
}
public UcumException(Throwable cause) {
super(cause);
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities;
/*
@ -48,45 +48,45 @@ package org.hl7.fhir.utilities;
* #L%
*/
import java.io.File;
import java.io.IOException;
/**
* Extends the usual Java File to make it case-sensitive: if the file to be opened has
* a different casing in the filesystem (but is found anyway base Windows is case-insensitive),
* the constructor will throw. Allows early detection of miscased filenames.
* @author Ewout
*
*/
public class CSFile extends File {
private static final long serialVersionUID = -2017155765132460726L;
public CSFile(String pathname) throws IOException {
super(pathname);
// if (exists() && getParent() != null)
// {
// String n = getName();
// File f = new File(getParent());
// String[] l = f.list();
// boolean ok = false;
// for (String n1 : l) {
// if (n1.equals(n))
// ok = true;
// }
// if (!ok)
// throw new Error("Case mismatch of file "+ pathname);
// }
//EK: Original code above looked extremely wasteful: every single
//attempt to open a file triggers a directory listing
if (exists())
{
if(!this.getCanonicalFile().getName().equals(this.getName()))
throw new Error("Case mismatch of file "+ pathname+": found "+this.getCanonicalFile().getName());
}
}
}
import java.io.File;
import java.io.IOException;
/**
* Extends the usual Java File to make it case-sensitive: if the file to be opened has
* a different casing in the filesystem (but is found anyway base Windows is case-insensitive),
* the constructor will throw. Allows early detection of miscased filenames.
* @author Ewout
*
*/
public class CSFile extends File {
private static final long serialVersionUID = -2017155765132460726L;
public CSFile(String pathname) throws IOException {
super(pathname);
// if (exists() && getParent() != null)
// {
// String n = getName();
// File f = new File(getParent());
// String[] l = f.list();
// boolean ok = false;
// for (String n1 : l) {
// if (n1.equals(n))
// ok = true;
// }
// if (!ok)
// throw new Error("Case mismatch of file "+ pathname);
// }
//EK: Original code above looked extremely wasteful: every single
//attempt to open a file triggers a directory listing
if (exists())
{
if(!this.getCanonicalFile().getName().equals(this.getName()))
throw new Error("Case mismatch of file "+ pathname+": found "+this.getCanonicalFile().getName());
}
}
}

View File

@ -20,35 +20,35 @@ package org.hl7.fhir.utilities;
* #L%
*/
/**
* Encapsulates StringBuilder to build strings of values separated by comma
* @author Ewout
*/
public class CommaSeparatedStringBuilder {
boolean first = true;
String sep = ", ";
StringBuilder b = new StringBuilder();
public CommaSeparatedStringBuilder() {
}
public CommaSeparatedStringBuilder(String sep) {
this.sep = sep;
}
public void append(String value) {
if (!first)
b.append(sep);
b.append(value);
first = false;
}
@Override
public String toString() {
return b.toString();
}
}
/**
* Encapsulates StringBuilder to build strings of values separated by comma
* @author Ewout
*/
public class CommaSeparatedStringBuilder {
boolean first = true;
String sep = ", ";
StringBuilder b = new StringBuilder();
public CommaSeparatedStringBuilder() {
}
public CommaSeparatedStringBuilder(String sep) {
this.sep = sep;
}
public void append(String value) {
if (!first)
b.append(sep);
b.append(value);
first = false;
}
@Override
public String toString() {
return b.toString();
}
}

View File

@ -20,9 +20,9 @@ package org.hl7.fhir.utilities;
* #L%
*/
public interface FileNotifier {
public void copyFile(String src, String dst);
}
public interface FileNotifier {
public void copyFile(String src, String dst);
}

View File

@ -20,76 +20,76 @@ package org.hl7.fhir.utilities;
* #L%
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
public class MyURIResolver implements URIResolver {
private String path;
private URIResolver alt;
public MyURIResolver(String path, URIResolver alt) {
super();
this.path = path;
this.alt = alt;
}
@Override
public Source resolve(String href, String base) throws TransformerException {
try {
if (href.startsWith("http://") || href.startsWith("https://")) {
if (alt != null) {
Source s = alt.resolve(href, base);
if (s != null)
return s;
}
return TransformerFactory.newInstance().getURIResolver().resolve(href, base);
} else
return new StreamSource(new FileInputStream(href.contains(File.separator) ? href : Utilities.path(path, href)));
} catch (FileNotFoundException e) {
throw new TransformerException(e);
} catch (IOException e) {
throw new TransformerException(e);
}
}
}
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
public class MyURIResolver implements URIResolver {
private String path;
private URIResolver alt;
public MyURIResolver(String path, URIResolver alt) {
super();
this.path = path;
this.alt = alt;
}
@Override
public Source resolve(String href, String base) throws TransformerException {
try {
if (href.startsWith("http://") || href.startsWith("https://")) {
if (alt != null) {
Source s = alt.resolve(href, base);
if (s != null)
return s;
}
return TransformerFactory.newInstance().getURIResolver().resolve(href, base);
} else
return new StreamSource(new FileInputStream(href.contains(File.separator) ? href : Utilities.path(path, href)));
} catch (FileNotFoundException e) {
throw new TransformerException(e);
} catch (IOException e) {
throw new TransformerException(e);
}
}
}

View File

@ -20,37 +20,37 @@ package org.hl7.fhir.utilities;
* #L%
*/
import java.util.ArrayList;
import java.util.List;
public class Table<T> {
private int rowCount;
private int colCount;
private List<List<T>> rows = new ArrayList<List<T>>();
public Table(int rowCount, int colCount) {
this.rowCount = rowCount;
this.colCount = colCount;
for (int r = 0; r < rowCount; r++) {
rows.add(new ArrayList<T>());
for (int c = 0; c < colCount; c++) {
rows.get(r).add(null);
}
}
}
public void setValue(int r, int c, T value) {
rows.get(r).set(c, value);
}
public T get(int r, int c) {
return rows.get(r).get(c);
}
public int colCount() {
return colCount;
}
}
import java.util.ArrayList;
import java.util.List;
public class Table<T> {
private int rowCount;
private int colCount;
private List<List<T>> rows = new ArrayList<List<T>>();
public Table(int rowCount, int colCount) {
this.rowCount = rowCount;
this.colCount = colCount;
for (int r = 0; r < rowCount; r++) {
rows.add(new ArrayList<T>());
for (int c = 0; c < colCount; c++) {
rows.get(r).add(null);
}
}
}
public void setValue(int r, int c, T value) {
rows.get(r).set(c, value);
}
public T get(int r, int c) {
return rows.get(r).get(c);
}
public int colCount() {
return colCount;
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities;
/*
@ -48,87 +48,87 @@ package org.hl7.fhir.utilities;
* #L%
*/
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Set of static helper functions to read lines from files, create files from lists of lines,
* read files into a single string and create files from a single string.
* @author Ewout
*
*/
public class TextFile {
public static List<String> readAllLines(String path) throws IOException
{
List<String> result = new ArrayList<String>();
File file = new CSFile(path);
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while( reader.ready() )
result.add(reader.readLine());
reader.close();
return result;
}
public static void writeAllLines(String path, List<String> lines) throws IOException
{
File file = new CSFile(path);
FileOutputStream s = new FileOutputStream(file);
OutputStreamWriter sw = new OutputStreamWriter(s, "UTF-8");
for( String line : lines )
sw.write(line + "\r\n");
sw.flush();
s.close();
}
public static void stringToFile(String content, String path) throws IOException {
File file = new CSFile(path);
OutputStreamWriter sw = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
sw.write('\ufeff'); // Unicode BOM, translates to UTF-8 with the configured outputstreamwriter
sw.write(content);
sw.flush();
sw.close();
}
public static void stringToFileNoPrefix(String content, String path) throws IOException {
File file = new CSFile(path);
OutputStreamWriter sw = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
sw.write(content);
sw.flush();
sw.close();
}
public static String fileToString(String src) throws FileNotFoundException, IOException {
return streamToString(new FileInputStream(new CSFile(src)));
}
public static String streamToString(InputStream input) throws IOException {
InputStreamReader sr = new InputStreamReader(input, "UTF-8");
StringBuilder b = new StringBuilder();
//while (sr.ready()) { Commented out by Claude Nanjo (1/14/2014) - sr.ready() always returns false - please remove if change does not impact other areas of codebase
int i = -1;
while((i = sr.read()) > -1) {
char c = (char) i;
b.append(c);
}
// sr.close();
return b.toString().replace("\uFEFF", "");
}
public static void bytesToFile(byte[] bytes, String path) throws IOException {
File file = new CSFile(path);
OutputStream sw = new FileOutputStream(file);
sw.write(bytes);
sw.flush();
sw.close();
}
}
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Set of static helper functions to read lines from files, create files from lists of lines,
* read files into a single string and create files from a single string.
* @author Ewout
*
*/
public class TextFile {
public static List<String> readAllLines(String path) throws IOException
{
List<String> result = new ArrayList<String>();
File file = new CSFile(path);
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while( reader.ready() )
result.add(reader.readLine());
reader.close();
return result;
}
public static void writeAllLines(String path, List<String> lines) throws IOException
{
File file = new CSFile(path);
FileOutputStream s = new FileOutputStream(file);
OutputStreamWriter sw = new OutputStreamWriter(s, "UTF-8");
for( String line : lines )
sw.write(line + "\r\n");
sw.flush();
s.close();
}
public static void stringToFile(String content, String path) throws IOException {
File file = new CSFile(path);
OutputStreamWriter sw = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
sw.write('\ufeff'); // Unicode BOM, translates to UTF-8 with the configured outputstreamwriter
sw.write(content);
sw.flush();
sw.close();
}
public static void stringToFileNoPrefix(String content, String path) throws IOException {
File file = new CSFile(path);
OutputStreamWriter sw = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
sw.write(content);
sw.flush();
sw.close();
}
public static String fileToString(String src) throws FileNotFoundException, IOException {
return streamToString(new FileInputStream(new CSFile(src)));
}
public static String streamToString(InputStream input) throws IOException {
InputStreamReader sr = new InputStreamReader(input, "UTF-8");
StringBuilder b = new StringBuilder();
//while (sr.ready()) { Commented out by Claude Nanjo (1/14/2014) - sr.ready() always returns false - please remove if change does not impact other areas of codebase
int i = -1;
while((i = sr.read()) > -1) {
char c = (char) i;
b.append(c);
}
// sr.close();
return b.toString().replace("\uFEFF", "");
}
public static void bytesToFile(byte[] bytes, String path) throws IOException {
File file = new CSFile(path);
OutputStream sw = new FileOutputStream(file);
sw.write(bytes);
sw.flush();
sw.close();
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities;
/*
@ -48,37 +48,37 @@ package org.hl7.fhir.utilities;
* #L%
*/
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
/**
* TextStream writer that helps to write indented text. ln_i() indents, ln_o() outdents.
* @author Ewout
*
*/
public class TextStreamWriter extends OutputStreamWriter {
public TextStreamWriter(OutputStream out) throws UnsupportedEncodingException {
super(out, "UTF-8");
}
private String indent = "";
public void ln(String line) throws IOException {
write(indent+line+"\r\n");
}
public void ln_i(String line) throws IOException {
ln(line);
indent = indent + " ";
}
public void ln_o(String line) throws IOException {
indent = indent.substring(0, indent.length()-2);
ln(line);
}
}
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
/**
* TextStream writer that helps to write indented text. ln_i() indents, ln_o() outdents.
* @author Ewout
*
*/
public class TextStreamWriter extends OutputStreamWriter {
public TextStreamWriter(OutputStream out) throws UnsupportedEncodingException {
super(out, "UTF-8");
}
private String indent = "";
public void ln(String line) throws IOException {
write(indent+line+"\r\n");
}
public void ln_i(String line) throws IOException {
ln(line);
indent = indent + " ";
}
public void ln_o(String line) throws IOException {
indent = indent.substring(0, indent.length()-2);
ln(line);
}
}

View File

@ -20,64 +20,64 @@ package org.hl7.fhir.utilities;
* #L%
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
import java.io.ByteArrayInputStream;
import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
public class ZipURIResolver implements URIResolver {
private Map<String, byte[]> files;
public ZipURIResolver(Map<String, byte[]> files) {
super();
this.files = files;
}
@Override
public Source resolve(String arg0, String arg1) throws TransformerException {
try {
byte[] bs = files.get(arg0);
return new StreamSource(new ByteArrayInputStream(bs));
} catch (Exception e) {
throw new TransformerException(e);
}
}
}
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
import java.io.ByteArrayInputStream;
import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
public class ZipURIResolver implements URIResolver {
private Map<String, byte[]> files;
public ZipURIResolver(Map<String, byte[]> files) {
super();
this.files = files;
}
@Override
public Source resolve(String arg0, String arg1) throws TransformerException {
try {
byte[] bs = files.get(arg0);
return new StreamSource(new ByteArrayInputStream(bs));
} catch (Exception e) {
throw new TransformerException(e);
}
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xhtml;
/*
@ -48,5 +48,5 @@ package org.hl7.fhir.utilities.xhtml;
* #L%
*/
public enum NodeType { Element, Text, Comment, DocType, Document, Instruction }
public enum NodeType { Element, Text, Comment, DocType, Document, Instruction }

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xhtml;
/*
@ -48,272 +48,272 @@ package org.hl7.fhir.utilities.xhtml;
* #L%
*/
import java.io.*;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xml.IXMLWriter;
import org.w3c.dom.Element;
public class XhtmlComposer {
public static final String XHTML_NS = "http://www.w3.org/1999/xhtml";
private boolean pretty;
private boolean xmlOnly;
public boolean isPretty() {
return pretty;
}
public void setPretty(boolean pretty) {
this.pretty = pretty;
}
public boolean isXmlOnly() {
return xmlOnly;
}
public XhtmlComposer setXmlOnly(boolean xmlOnly) {
this.xmlOnly = xmlOnly;
return this;
}
private Writer dst;
public String compose(XhtmlDocument doc) throws IOException, FHIRException {
StringWriter sdst = new StringWriter();
dst = sdst;
composeDoc(doc);
return sdst.toString();
}
public String compose(XhtmlNode node) throws IOException {
StringWriter sdst = new StringWriter();
dst = sdst;
writeNode("", node);
return sdst.toString();
}
public void compose(OutputStream stream, XhtmlDocument doc) throws IOException, FHIRException {
byte[] bom = new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF };
stream.write(bom);
dst = new OutputStreamWriter(stream, "UTF-8");
composeDoc(doc);
dst.flush();
}
private void composeDoc(XhtmlDocument doc) throws IOException, FHIRException {
// headers....
// dst.append("<html>" + (isPretty() ? "\r\n" : ""));
for (XhtmlNode c : doc.getChildNodes())
writeNode(" ", c);
// dst.append("</html>" + (isPretty() ? "\r\n" : ""));
}
private void writeNode(String indent, XhtmlNode node) throws IOException {
if (node.getNodeType() == NodeType.Comment)
writeComment(indent, node);
else if (node.getNodeType() == NodeType.DocType)
writeDocType(node);
else if (node.getNodeType() == NodeType.Instruction)
writeInstruction(node);
else if (node.getNodeType() == NodeType.Element)
writeElement(indent, node);
else if (node.getNodeType() == NodeType.Text)
writeText(node);
else
throw new Error("Unknown node type: "+node.getNodeType().toString());
}
private void writeText(XhtmlNode node) throws IOException {
for (char c : node.getContent().toCharArray())
{
if (c == '&')
dst.append("&amp;");
else if (c == '<')
dst.append("&lt;");
else if (c == '>')
dst.append("&gt;");
else if (c == '"')
dst.append("&quot;");
else if (!xmlOnly) {
dst.append(c);
} else {
if (c == XhtmlNode.NBSP.charAt(0))
dst.append("&nbsp;");
else if (c == (char) 0xA7)
dst.append("&sect;");
else if (c == (char) 169)
dst.append("&copy;");
else if (c == (char) 8482)
dst.append("&trade;");
else if (c == (char) 956)
dst.append("&mu;");
else if (c == (char) 174)
dst.append("&reg;");
else
dst.append(c);
}
}
}
private void writeComment(String indent, XhtmlNode node) throws IOException {
dst.append(indent + "<!-- " + node.getContent().trim() + " -->" + (isPretty() ? "\r\n" : ""));
}
private void writeDocType(XhtmlNode node) throws IOException {
dst.append("<!" + node.getContent() + ">\r\n");
}
private void writeInstruction(XhtmlNode node) throws IOException {
dst.append("<?" + node.getContent() + "?>\r\n");
}
private String escapeHtml(String s) {
if (s == null || s.equals(""))
return null;
StringBuilder b = new StringBuilder();
for (char c : s.toCharArray())
if (c == '<')
b.append("&lt;");
else if (c == '>')
b.append("&gt;");
else if (c == '"')
b.append("&quot;");
else if (c == '&')
b.append("&amp;");
else
b.append(c);
return b.toString();
}
private String attributes(XhtmlNode node) {
StringBuilder s = new StringBuilder();
for (String n : node.getAttributes().keySet())
s.append(" " + n + "=\"" + escapeHtml(node.getAttributes().get(n)) + "\"");
return s.toString();
}
private void writeElement(String indent, XhtmlNode node) throws IOException {
if (!pretty)
indent = "";
if (node.getChildNodes().size() == 0)
dst.append(indent + "<" + node.getName() + attributes(node) + "/>" + (isPretty() ? "\r\n" : ""));
else {
boolean act = node.allChildrenAreText();
if (act || !pretty)
dst.append(indent + "<" + node.getName() + attributes(node)+">");
else
dst.append(indent + "<" + node.getName() + attributes(node) + ">\r\n");
if (node.getName() == "head" && node.getElement("meta") == null)
dst.append(indent + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + (isPretty() ? "\r\n" : ""));
for (XhtmlNode c : node.getChildNodes())
writeNode(indent + " ", c);
if (act)
dst.append("</" + node.getName() + ">" + (isPretty() ? "\r\n" : ""));
else if (node.getChildNodes().get(node.getChildNodes().size() - 1).getNodeType() == NodeType.Text)
dst.append((isPretty() ? "\r\n"+ indent : "") + "</" + node.getName() + ">" + (isPretty() ? "\r\n" : ""));
else
dst.append(indent + "</" + node.getName() + ">" + (isPretty() ? "\r\n" : ""));
}
}
public void compose(IXMLWriter xml, XhtmlNode node) throws IOException {
if (node.getNodeType() == NodeType.Comment)
xml.comment(node.getContent(), isPretty());
else if (node.getNodeType() == NodeType.Element)
composeElement(xml, node);
else if (node.getNodeType() == NodeType.Text)
xml.text(node.getContent());
else
throw new Error("Unhandled node type: "+node.getNodeType().toString());
}
private void composeElement(IXMLWriter xml, XhtmlNode node) throws IOException {
for (String n : node.getAttributes().keySet())
xml.attribute(n, node.getAttributes().get(n));
xml.enter(XHTML_NS, node.getName());
for (XhtmlNode n : node.getChildNodes())
compose(xml, n);
xml.exit(XHTML_NS, node.getName());
}
public String composePlainText(XhtmlNode x) {
StringBuilder b = new StringBuilder();
composePlainText(x, b, false);
return b.toString().trim();
}
private boolean composePlainText(XhtmlNode x, StringBuilder b, boolean lastWS) {
if (x.getNodeType() == NodeType.Text) {
String s = x.getContent();
if (!lastWS & (s.startsWith(" ") || s.startsWith("\r") || s.startsWith("\n") || s.endsWith("\t"))) {
b.append(" ");
lastWS = true;
}
String st = s.trim().replace("\r", " ").replace("\n", " ").replace("\t", " ");
while (st.contains(" "))
st = st.replace(" ", " ");
if (!Utilities.noString(st)) {
b.append(st);
lastWS = false;
if (!lastWS & (s.endsWith(" ") || s.endsWith("\r") || s.endsWith("\n") || s.endsWith("\t"))) {
b.append(" ");
lastWS = true;
}
}
return lastWS;
} else if (x.getNodeType() == NodeType.Element) {
if (x.getName().equals("li")) {
b.append("* ");
lastWS = true;
}
for (XhtmlNode n : x.getChildNodes()) {
lastWS = composePlainText(n, b, lastWS);
}
if (x.getName().equals("p")) {
b.append("\r\n\r\n");
lastWS = true;
}
if (x.getName().equals("br") || x.getName().equals("li")) {
b.append("\r\n");
lastWS = true;
}
return lastWS;
} else
return lastWS;
}
public void compose(Element div, XhtmlNode x) {
for (XhtmlNode child : x.getChildNodes()) {
appendChild(div, child);
}
}
private void appendChild(Element e, XhtmlNode node) {
if (node.getNodeType() == NodeType.Comment)
e.appendChild(e.getOwnerDocument().createComment(node.getContent()));
else if (node.getNodeType() == NodeType.DocType)
throw new Error("not done yet");
else if (node.getNodeType() == NodeType.Instruction)
e.appendChild(e.getOwnerDocument().createProcessingInstruction("", node.getContent()));
else if (node.getNodeType() == NodeType.Text)
e.appendChild(e.getOwnerDocument().createTextNode(node.getContent()));
else if (node.getNodeType() == NodeType.Element) {
Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName());
e.appendChild(child);
for (XhtmlNode c : node.getChildNodes()) {
appendChild(child, c);
}
} else
throw new Error("Unknown node type: "+node.getNodeType().toString());
}
}
import java.io.*;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xml.IXMLWriter;
import org.w3c.dom.Element;
public class XhtmlComposer {
public static final String XHTML_NS = "http://www.w3.org/1999/xhtml";
private boolean pretty;
private boolean xmlOnly;
public boolean isPretty() {
return pretty;
}
public void setPretty(boolean pretty) {
this.pretty = pretty;
}
public boolean isXmlOnly() {
return xmlOnly;
}
public XhtmlComposer setXmlOnly(boolean xmlOnly) {
this.xmlOnly = xmlOnly;
return this;
}
private Writer dst;
public String compose(XhtmlDocument doc) throws IOException, FHIRException {
StringWriter sdst = new StringWriter();
dst = sdst;
composeDoc(doc);
return sdst.toString();
}
public String compose(XhtmlNode node) throws IOException {
StringWriter sdst = new StringWriter();
dst = sdst;
writeNode("", node);
return sdst.toString();
}
public void compose(OutputStream stream, XhtmlDocument doc) throws IOException, FHIRException {
byte[] bom = new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF };
stream.write(bom);
dst = new OutputStreamWriter(stream, "UTF-8");
composeDoc(doc);
dst.flush();
}
private void composeDoc(XhtmlDocument doc) throws IOException, FHIRException {
// headers....
// dst.append("<html>" + (isPretty() ? "\r\n" : ""));
for (XhtmlNode c : doc.getChildNodes())
writeNode(" ", c);
// dst.append("</html>" + (isPretty() ? "\r\n" : ""));
}
private void writeNode(String indent, XhtmlNode node) throws IOException {
if (node.getNodeType() == NodeType.Comment)
writeComment(indent, node);
else if (node.getNodeType() == NodeType.DocType)
writeDocType(node);
else if (node.getNodeType() == NodeType.Instruction)
writeInstruction(node);
else if (node.getNodeType() == NodeType.Element)
writeElement(indent, node);
else if (node.getNodeType() == NodeType.Text)
writeText(node);
else
throw new Error("Unknown node type: "+node.getNodeType().toString());
}
private void writeText(XhtmlNode node) throws IOException {
for (char c : node.getContent().toCharArray())
{
if (c == '&')
dst.append("&amp;");
else if (c == '<')
dst.append("&lt;");
else if (c == '>')
dst.append("&gt;");
else if (c == '"')
dst.append("&quot;");
else if (!xmlOnly) {
dst.append(c);
} else {
if (c == XhtmlNode.NBSP.charAt(0))
dst.append("&nbsp;");
else if (c == (char) 0xA7)
dst.append("&sect;");
else if (c == (char) 169)
dst.append("&copy;");
else if (c == (char) 8482)
dst.append("&trade;");
else if (c == (char) 956)
dst.append("&mu;");
else if (c == (char) 174)
dst.append("&reg;");
else
dst.append(c);
}
}
}
private void writeComment(String indent, XhtmlNode node) throws IOException {
dst.append(indent + "<!-- " + node.getContent().trim() + " -->" + (isPretty() ? "\r\n" : ""));
}
private void writeDocType(XhtmlNode node) throws IOException {
dst.append("<!" + node.getContent() + ">\r\n");
}
private void writeInstruction(XhtmlNode node) throws IOException {
dst.append("<?" + node.getContent() + "?>\r\n");
}
private String escapeHtml(String s) {
if (s == null || s.equals(""))
return null;
StringBuilder b = new StringBuilder();
for (char c : s.toCharArray())
if (c == '<')
b.append("&lt;");
else if (c == '>')
b.append("&gt;");
else if (c == '"')
b.append("&quot;");
else if (c == '&')
b.append("&amp;");
else
b.append(c);
return b.toString();
}
private String attributes(XhtmlNode node) {
StringBuilder s = new StringBuilder();
for (String n : node.getAttributes().keySet())
s.append(" " + n + "=\"" + escapeHtml(node.getAttributes().get(n)) + "\"");
return s.toString();
}
private void writeElement(String indent, XhtmlNode node) throws IOException {
if (!pretty)
indent = "";
if (node.getChildNodes().size() == 0)
dst.append(indent + "<" + node.getName() + attributes(node) + "/>" + (isPretty() ? "\r\n" : ""));
else {
boolean act = node.allChildrenAreText();
if (act || !pretty)
dst.append(indent + "<" + node.getName() + attributes(node)+">");
else
dst.append(indent + "<" + node.getName() + attributes(node) + ">\r\n");
if (node.getName() == "head" && node.getElement("meta") == null)
dst.append(indent + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + (isPretty() ? "\r\n" : ""));
for (XhtmlNode c : node.getChildNodes())
writeNode(indent + " ", c);
if (act)
dst.append("</" + node.getName() + ">" + (isPretty() ? "\r\n" : ""));
else if (node.getChildNodes().get(node.getChildNodes().size() - 1).getNodeType() == NodeType.Text)
dst.append((isPretty() ? "\r\n"+ indent : "") + "</" + node.getName() + ">" + (isPretty() ? "\r\n" : ""));
else
dst.append(indent + "</" + node.getName() + ">" + (isPretty() ? "\r\n" : ""));
}
}
public void compose(IXMLWriter xml, XhtmlNode node) throws IOException {
if (node.getNodeType() == NodeType.Comment)
xml.comment(node.getContent(), isPretty());
else if (node.getNodeType() == NodeType.Element)
composeElement(xml, node);
else if (node.getNodeType() == NodeType.Text)
xml.text(node.getContent());
else
throw new Error("Unhandled node type: "+node.getNodeType().toString());
}
private void composeElement(IXMLWriter xml, XhtmlNode node) throws IOException {
for (String n : node.getAttributes().keySet())
xml.attribute(n, node.getAttributes().get(n));
xml.enter(XHTML_NS, node.getName());
for (XhtmlNode n : node.getChildNodes())
compose(xml, n);
xml.exit(XHTML_NS, node.getName());
}
public String composePlainText(XhtmlNode x) {
StringBuilder b = new StringBuilder();
composePlainText(x, b, false);
return b.toString().trim();
}
private boolean composePlainText(XhtmlNode x, StringBuilder b, boolean lastWS) {
if (x.getNodeType() == NodeType.Text) {
String s = x.getContent();
if (!lastWS & (s.startsWith(" ") || s.startsWith("\r") || s.startsWith("\n") || s.endsWith("\t"))) {
b.append(" ");
lastWS = true;
}
String st = s.trim().replace("\r", " ").replace("\n", " ").replace("\t", " ");
while (st.contains(" "))
st = st.replace(" ", " ");
if (!Utilities.noString(st)) {
b.append(st);
lastWS = false;
if (!lastWS & (s.endsWith(" ") || s.endsWith("\r") || s.endsWith("\n") || s.endsWith("\t"))) {
b.append(" ");
lastWS = true;
}
}
return lastWS;
} else if (x.getNodeType() == NodeType.Element) {
if (x.getName().equals("li")) {
b.append("* ");
lastWS = true;
}
for (XhtmlNode n : x.getChildNodes()) {
lastWS = composePlainText(n, b, lastWS);
}
if (x.getName().equals("p")) {
b.append("\r\n\r\n");
lastWS = true;
}
if (x.getName().equals("br") || x.getName().equals("li")) {
b.append("\r\n");
lastWS = true;
}
return lastWS;
} else
return lastWS;
}
public void compose(Element div, XhtmlNode x) {
for (XhtmlNode child : x.getChildNodes()) {
appendChild(div, child);
}
}
private void appendChild(Element e, XhtmlNode node) {
if (node.getNodeType() == NodeType.Comment)
e.appendChild(e.getOwnerDocument().createComment(node.getContent()));
else if (node.getNodeType() == NodeType.DocType)
throw new Error("not done yet");
else if (node.getNodeType() == NodeType.Instruction)
e.appendChild(e.getOwnerDocument().createProcessingInstruction("", node.getContent()));
else if (node.getNodeType() == NodeType.Text)
e.appendChild(e.getOwnerDocument().createTextNode(node.getContent()));
else if (node.getNodeType() == NodeType.Element) {
Element child = e.getOwnerDocument().createElementNS(XHTML_NS, node.getName());
e.appendChild(child);
for (XhtmlNode c : node.getChildNodes()) {
appendChild(child, c);
}
} else
throw new Error("Unknown node type: "+node.getNodeType().toString());
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xhtml;
/*
@ -48,18 +48,18 @@ package org.hl7.fhir.utilities.xhtml;
* #L%
*/
public class XhtmlDocument extends XhtmlNode {
public XhtmlDocument() {
super(NodeType.Document);
}
public XhtmlNode getDocumentElement() {
for (XhtmlNode n : getChildNodes()) {
if (n.getNodeType() == NodeType.Element)
return n;
}
return null;
}
}
public class XhtmlDocument extends XhtmlNode {
public XhtmlDocument() {
super(NodeType.Document);
}
public XhtmlNode getDocumentElement() {
for (XhtmlNode n : getChildNodes()) {
if (n.getNodeType() == NodeType.Element)
return n;
}
return null;
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xhtml;
/*
@ -48,413 +48,413 @@ package org.hl7.fhir.utilities.xhtml;
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hl7.fhir.instance.model.api.IBaseXhtml;
import ca.uhn.fhir.model.primitive.XhtmlDt;
@ca.uhn.fhir.model.api.annotation.DatatypeDef(name="xhtml")
public class XhtmlNode implements IBaseXhtml {
private static final long serialVersionUID = -4362547161441436492L;
public static class Location {
private int line;
private int column;
public Location(int line, int column) {
super();
this.line = line;
this.column = column;
}
public int getLine() {
return line;
}
public int getColumn() {
return column;
}
@Override
public String toString() {
return "Line "+Integer.toString(line)+", column "+Integer.toString(column);
}
}
public static final String NBSP = Character.toString((char)0xa0);
private static final String DECL_XMLNS = " xmlns=\"http://www.w3.org/1999/xhtml\"";
private Location location;
private NodeType nodeType;
private String name;
private Map<String, String> attributes = new HashMap<String, String>();
private List<XhtmlNode> childNodes = new ArrayList<XhtmlNode>();
private String content;
public XhtmlNode() {
super();
}
public XhtmlNode(NodeType nodeType, String name) {
super();
this.nodeType = nodeType;
this.name = name;
}
public XhtmlNode(NodeType nodeType) {
super();
this.nodeType = nodeType;
}
public NodeType getNodeType() {
return nodeType;
}
public void setNodeType(NodeType nodeType) {
this.nodeType = nodeType;
}
public String getName() {
return name;
}
public void setName(String name) {
assert name.contains(":") == false : "Name should not contain any : but was " + name;
this.name = name;
}
public Map<String, String> getAttributes() {
return attributes;
}
public List<XhtmlNode> getChildNodes() {
return childNodes;
}
public String getContent() {
return content;
}
public XhtmlNode setContent(String content) {
if (!(nodeType != NodeType.Text || nodeType != NodeType.Comment))
throw new Error("Wrong node type");
this.content = content;
return this;
}
public XhtmlNode addTag(String name)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type. is "+nodeType.toString());
XhtmlNode node = new XhtmlNode(NodeType.Element);
node.setName(name);
childNodes.add(node);
return node;
}
public XhtmlNode addTag(int index, String name)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type. is "+nodeType.toString());
XhtmlNode node = new XhtmlNode(NodeType.Element);
node.setName(name);
childNodes.add(index, node);
return node;
}
public XhtmlNode addComment(String content)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
XhtmlNode node = new XhtmlNode(NodeType.Comment);
node.setContent(content);
childNodes.add(node);
return node;
}
public XhtmlNode addDocType(String content)
{
if (!(nodeType == NodeType.Document))
throw new Error("Wrong node type");
XhtmlNode node = new XhtmlNode(NodeType.DocType);
node.setContent(content);
childNodes.add(node);
return node;
}
public XhtmlNode addInstruction(String content)
{
if (!(nodeType == NodeType.Document))
throw new Error("Wrong node type");
XhtmlNode node = new XhtmlNode(NodeType.Instruction);
node.setContent(content);
childNodes.add(node);
return node;
}
public XhtmlNode addText(String content)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
if (content != null) {
XhtmlNode node = new XhtmlNode(NodeType.Text);
node.setContent(content);
childNodes.add(node);
return node;
} else
return null;
}
public XhtmlNode addText(int index, String content)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
if (content == null)
throw new Error("Content cannot be null");
XhtmlNode node = new XhtmlNode(NodeType.Text);
node.setContent(content);
childNodes.add(index, node);
return node;
}
public boolean allChildrenAreText()
{
boolean res = true;
for (XhtmlNode n : childNodes)
res = res && n.getNodeType() == NodeType.Text;
return res;
}
public XhtmlNode getElement(String name)
{
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Element && name.equals(n.getName()))
return n;
return null;
}
public XhtmlNode getFirstElement()
{
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Element)
return n;
return null;
}
public String allText() {
StringBuilder b = new StringBuilder();
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Text)
b.append(n.getContent());
else if (n.getNodeType() == NodeType.Element)
b.append(n.allText());
return b.toString();
}
public XhtmlNode attribute(String name, String value) {
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
if (name == null)
throw new Error("name is null");
if (value == null)
throw new Error("value is null");
attributes.put(name, value);
return this;
}
public boolean hasAttribute(String name) {
return getAttributes().containsKey(name);
}
public String getAttribute(String name) {
return getAttributes().get(name);
}
public XhtmlNode setAttribute(String name, String value) {
getAttributes().put(name, value);
return this;
}
public XhtmlNode copy() {
XhtmlNode dst = new XhtmlNode(nodeType);
dst.name = name;
for (String n : attributes.keySet()) {
dst.attributes.put(n, attributes.get(n));
}
for (XhtmlNode n : childNodes)
dst.childNodes.add(n.copy());
dst.content = content;
return dst;
}
@Override
public boolean isEmpty() {
return (childNodes == null || childNodes.isEmpty()) && content == null;
}
public boolean equalsDeep(XhtmlNode other) {
if (other == null) {
return false;
}
if (!(nodeType == other.nodeType) || !compare(name, other.name) || !compare(content, other.content))
return false;
if (attributes.size() != other.attributes.size())
return false;
for (String an : attributes.keySet())
if (!attributes.get(an).equals(other.attributes.get(an)))
return false;
if (childNodes.size() != other.childNodes.size())
return false;
for (int i = 0; i < childNodes.size(); i++) {
if (!compareDeep(childNodes.get(i), other.childNodes.get(i)))
return false;
}
return true;
}
private boolean compare(String s1, String s2) {
if (s1 == null && s2 == null)
return true;
if (s1 == null || s2 == null)
return false;
return s1.equals(s2);
}
private static boolean compareDeep(XhtmlNode e1, XhtmlNode e2) {
if (e1 == null && e2 == null)
return true;
if (e1 == null || e2 == null)
return false;
return e1.equalsDeep(e2);
}
public String getNsDecl() {
for (String an : attributes.keySet()) {
if (an.equals("xmlns")) {
return attributes.get(an);
}
}
return null;
}
@Override
public String getValueAsString() {
if (isEmpty()) {
return null;
}
try {
String retVal = new XhtmlComposer().compose(this);
retVal = XhtmlDt.preprocessXhtmlNamespaceDeclaration(retVal);
return retVal;
} catch (Exception e) {
// TODO: composer shouldn't throw exception like this
throw new RuntimeException(e);
}
}
@Override
public void setValueAsString(String theValue) throws IllegalArgumentException {
this.attributes = null;
this.childNodes = null;
this.content = null;
this.name = null;
this.nodeType= null;
if (isBlank(theValue)) {
return;
}
String val = theValue.trim();
if (!val.startsWith("<")) {
val = "<div" + DECL_XMLNS +">" + val + "</div>";
}
if (val.startsWith("<?") && val.endsWith("?>")) {
return;
}
val = XhtmlDt.preprocessXhtmlNamespaceDeclaration(val);
try {
// TODO: this is ugly
XhtmlNode fragment = new XhtmlParser().parseFragment(val);
this.attributes = fragment.attributes;
this.childNodes = fragment.childNodes;
this.content = fragment.content;
this.name = fragment.name;
this.nodeType= fragment.nodeType;
} catch (Exception e) {
// TODO: composer shouldn't throw exception like this
throw new RuntimeException(e);
}
}
public XhtmlNode getElementByIndex(int i) {
int c = 0;
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Element) {
if (c == i)
return n;
else
c++;
}
return null;
}
@Override
public String getValue() {
return getValueAsString();
}
@Override
public XhtmlNode setValue(String theValue) throws IllegalArgumentException {
setValueAsString(theValue);
return this;
}
/**
* Returns false
*/
public boolean hasFormatComment() {
return false;
}
/**
* NOT SUPPORTED - Throws {@link UnsupportedOperationException}
*/
public List<String> getFormatCommentsPre() {
throw new UnsupportedOperationException();
}
/**
* NOT SUPPORTED - Throws {@link UnsupportedOperationException}
*/
public List<String> getFormatCommentsPost() {
throw new UnsupportedOperationException();
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
}
import static org.apache.commons.lang3.StringUtils.isBlank;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hl7.fhir.instance.model.api.IBaseXhtml;
import ca.uhn.fhir.model.primitive.XhtmlDt;
@ca.uhn.fhir.model.api.annotation.DatatypeDef(name="xhtml")
public class XhtmlNode implements IBaseXhtml {
private static final long serialVersionUID = -4362547161441436492L;
public static class Location {
private int line;
private int column;
public Location(int line, int column) {
super();
this.line = line;
this.column = column;
}
public int getLine() {
return line;
}
public int getColumn() {
return column;
}
@Override
public String toString() {
return "Line "+Integer.toString(line)+", column "+Integer.toString(column);
}
}
public static final String NBSP = Character.toString((char)0xa0);
private static final String DECL_XMLNS = " xmlns=\"http://www.w3.org/1999/xhtml\"";
private Location location;
private NodeType nodeType;
private String name;
private Map<String, String> attributes = new HashMap<String, String>();
private List<XhtmlNode> childNodes = new ArrayList<XhtmlNode>();
private String content;
public XhtmlNode() {
super();
}
public XhtmlNode(NodeType nodeType, String name) {
super();
this.nodeType = nodeType;
this.name = name;
}
public XhtmlNode(NodeType nodeType) {
super();
this.nodeType = nodeType;
}
public NodeType getNodeType() {
return nodeType;
}
public void setNodeType(NodeType nodeType) {
this.nodeType = nodeType;
}
public String getName() {
return name;
}
public void setName(String name) {
assert name.contains(":") == false : "Name should not contain any : but was " + name;
this.name = name;
}
public Map<String, String> getAttributes() {
return attributes;
}
public List<XhtmlNode> getChildNodes() {
return childNodes;
}
public String getContent() {
return content;
}
public XhtmlNode setContent(String content) {
if (!(nodeType != NodeType.Text || nodeType != NodeType.Comment))
throw new Error("Wrong node type");
this.content = content;
return this;
}
public XhtmlNode addTag(String name)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type. is "+nodeType.toString());
XhtmlNode node = new XhtmlNode(NodeType.Element);
node.setName(name);
childNodes.add(node);
return node;
}
public XhtmlNode addTag(int index, String name)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type. is "+nodeType.toString());
XhtmlNode node = new XhtmlNode(NodeType.Element);
node.setName(name);
childNodes.add(index, node);
return node;
}
public XhtmlNode addComment(String content)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
XhtmlNode node = new XhtmlNode(NodeType.Comment);
node.setContent(content);
childNodes.add(node);
return node;
}
public XhtmlNode addDocType(String content)
{
if (!(nodeType == NodeType.Document))
throw new Error("Wrong node type");
XhtmlNode node = new XhtmlNode(NodeType.DocType);
node.setContent(content);
childNodes.add(node);
return node;
}
public XhtmlNode addInstruction(String content)
{
if (!(nodeType == NodeType.Document))
throw new Error("Wrong node type");
XhtmlNode node = new XhtmlNode(NodeType.Instruction);
node.setContent(content);
childNodes.add(node);
return node;
}
public XhtmlNode addText(String content)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
if (content != null) {
XhtmlNode node = new XhtmlNode(NodeType.Text);
node.setContent(content);
childNodes.add(node);
return node;
} else
return null;
}
public XhtmlNode addText(int index, String content)
{
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
if (content == null)
throw new Error("Content cannot be null");
XhtmlNode node = new XhtmlNode(NodeType.Text);
node.setContent(content);
childNodes.add(index, node);
return node;
}
public boolean allChildrenAreText()
{
boolean res = true;
for (XhtmlNode n : childNodes)
res = res && n.getNodeType() == NodeType.Text;
return res;
}
public XhtmlNode getElement(String name)
{
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Element && name.equals(n.getName()))
return n;
return null;
}
public XhtmlNode getFirstElement()
{
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Element)
return n;
return null;
}
public String allText() {
StringBuilder b = new StringBuilder();
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Text)
b.append(n.getContent());
else if (n.getNodeType() == NodeType.Element)
b.append(n.allText());
return b.toString();
}
public XhtmlNode attribute(String name, String value) {
if (!(nodeType == NodeType.Element || nodeType == NodeType.Document))
throw new Error("Wrong node type");
if (name == null)
throw new Error("name is null");
if (value == null)
throw new Error("value is null");
attributes.put(name, value);
return this;
}
public boolean hasAttribute(String name) {
return getAttributes().containsKey(name);
}
public String getAttribute(String name) {
return getAttributes().get(name);
}
public XhtmlNode setAttribute(String name, String value) {
getAttributes().put(name, value);
return this;
}
public XhtmlNode copy() {
XhtmlNode dst = new XhtmlNode(nodeType);
dst.name = name;
for (String n : attributes.keySet()) {
dst.attributes.put(n, attributes.get(n));
}
for (XhtmlNode n : childNodes)
dst.childNodes.add(n.copy());
dst.content = content;
return dst;
}
@Override
public boolean isEmpty() {
return (childNodes == null || childNodes.isEmpty()) && content == null;
}
public boolean equalsDeep(XhtmlNode other) {
if (other == null) {
return false;
}
if (!(nodeType == other.nodeType) || !compare(name, other.name) || !compare(content, other.content))
return false;
if (attributes.size() != other.attributes.size())
return false;
for (String an : attributes.keySet())
if (!attributes.get(an).equals(other.attributes.get(an)))
return false;
if (childNodes.size() != other.childNodes.size())
return false;
for (int i = 0; i < childNodes.size(); i++) {
if (!compareDeep(childNodes.get(i), other.childNodes.get(i)))
return false;
}
return true;
}
private boolean compare(String s1, String s2) {
if (s1 == null && s2 == null)
return true;
if (s1 == null || s2 == null)
return false;
return s1.equals(s2);
}
private static boolean compareDeep(XhtmlNode e1, XhtmlNode e2) {
if (e1 == null && e2 == null)
return true;
if (e1 == null || e2 == null)
return false;
return e1.equalsDeep(e2);
}
public String getNsDecl() {
for (String an : attributes.keySet()) {
if (an.equals("xmlns")) {
return attributes.get(an);
}
}
return null;
}
@Override
public String getValueAsString() {
if (isEmpty()) {
return null;
}
try {
String retVal = new XhtmlComposer().compose(this);
retVal = XhtmlDt.preprocessXhtmlNamespaceDeclaration(retVal);
return retVal;
} catch (Exception e) {
// TODO: composer shouldn't throw exception like this
throw new RuntimeException(e);
}
}
@Override
public void setValueAsString(String theValue) throws IllegalArgumentException {
this.attributes = null;
this.childNodes = null;
this.content = null;
this.name = null;
this.nodeType= null;
if (isBlank(theValue)) {
return;
}
String val = theValue.trim();
if (!val.startsWith("<")) {
val = "<div" + DECL_XMLNS +">" + val + "</div>";
}
if (val.startsWith("<?") && val.endsWith("?>")) {
return;
}
val = XhtmlDt.preprocessXhtmlNamespaceDeclaration(val);
try {
// TODO: this is ugly
XhtmlNode fragment = new XhtmlParser().parseFragment(val);
this.attributes = fragment.attributes;
this.childNodes = fragment.childNodes;
this.content = fragment.content;
this.name = fragment.name;
this.nodeType= fragment.nodeType;
} catch (Exception e) {
// TODO: composer shouldn't throw exception like this
throw new RuntimeException(e);
}
}
public XhtmlNode getElementByIndex(int i) {
int c = 0;
for (XhtmlNode n : childNodes)
if (n.getNodeType() == NodeType.Element) {
if (c == i)
return n;
else
c++;
}
return null;
}
@Override
public String getValue() {
return getValueAsString();
}
@Override
public XhtmlNode setValue(String theValue) throws IllegalArgumentException {
setValueAsString(theValue);
return this;
}
/**
* Returns false
*/
public boolean hasFormatComment() {
return false;
}
/**
* NOT SUPPORTED - Throws {@link UnsupportedOperationException}
*/
public List<String> getFormatCommentsPre() {
throw new UnsupportedOperationException();
}
/**
* NOT SUPPORTED - Throws {@link UnsupportedOperationException}
*/
public List<String> getFormatCommentsPost() {
throw new UnsupportedOperationException();
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xml;
/*
@ -48,72 +48,72 @@ package org.hl7.fhir.utilities.xml;
* #L%
*/
import java.io.IOException;
/**
* Generalize
* @author dennisn
*/
public interface IXMLWriter {
public abstract void start() throws IOException;
public abstract void end() throws IOException;
public abstract void attribute(String namespace, String name, String value, boolean onlyIfNotEmpty) throws IOException;
public abstract void attribute(String namespace, String name, String value) throws IOException;
public abstract void attribute(String name, String value, boolean onlyIfNotEmpty) throws IOException;
public abstract void attribute(String name, String value) throws IOException;
public abstract void attributeNoLines(String name, String value) throws IOException;
public abstract boolean namespaceDefined(String namespace);
public abstract boolean abbreviationDefined(String abbreviation);
public abstract String getDefaultNamespace();
public abstract void namespace(String namespace) throws IOException;
public abstract void setDefaultNamespace(String namespace) throws IOException;
public abstract void namespace(String namespace, String abbreviation) throws IOException;
public abstract void comment(String comment, boolean doPretty) throws IOException;
public abstract void enter(String name) throws IOException;
public abstract void enter(String namespace, String name) throws IOException;
public abstract void enter(String namespace, String name, String comment) throws IOException;
public abstract void exit() throws IOException;
public abstract void exit(String name) throws IOException;
public abstract void exit(String namespace, String name) throws IOException;
public abstract void exitToLevel(int count) throws IOException;
public abstract void element(String namespace, String name, String content, boolean onlyIfNotEmpty) throws IOException;
public abstract void element(String namespace, String name, String content, String comment) throws IOException;
public abstract void element(String namespace, String name, String content) throws IOException;
public abstract void element(String name, String content, boolean onlyIfNotEmpty) throws IOException;
public abstract void element(String name, String content) throws IOException;
public abstract void element(String name) throws IOException;
public abstract void text(String content) throws IOException;
public abstract void text(String content, boolean dontEscape) throws IOException;
public abstract void cData(String text) throws IOException;
public abstract void writeBytes(byte[] bytes) throws IOException;
public abstract boolean isPretty() throws IOException;
public abstract void setPretty(boolean pretty) throws IOException;
/**
* Start comment inserts a <!-- in the stream, but allows the user to
* go on creating xml content as usual, with proper formatting applied etc.
* Any comments inserted inside a comment will be terminated with -- > instead of -->
* so the comment doesn't close prematurely.
* @throws IOException
*/
public abstract void startCommentBlock() throws IOException;
public abstract void endCommentBlock() throws IOException;
public abstract void escapedText(String content) throws IOException;
// this is only implemented by an implementation that is producing an xhtml representation, and is able to render elements as hyperlinks
public abstract void link(String href);
}
import java.io.IOException;
/**
* Generalize
* @author dennisn
*/
public interface IXMLWriter {
public abstract void start() throws IOException;
public abstract void end() throws IOException;
public abstract void attribute(String namespace, String name, String value, boolean onlyIfNotEmpty) throws IOException;
public abstract void attribute(String namespace, String name, String value) throws IOException;
public abstract void attribute(String name, String value, boolean onlyIfNotEmpty) throws IOException;
public abstract void attribute(String name, String value) throws IOException;
public abstract void attributeNoLines(String name, String value) throws IOException;
public abstract boolean namespaceDefined(String namespace);
public abstract boolean abbreviationDefined(String abbreviation);
public abstract String getDefaultNamespace();
public abstract void namespace(String namespace) throws IOException;
public abstract void setDefaultNamespace(String namespace) throws IOException;
public abstract void namespace(String namespace, String abbreviation) throws IOException;
public abstract void comment(String comment, boolean doPretty) throws IOException;
public abstract void enter(String name) throws IOException;
public abstract void enter(String namespace, String name) throws IOException;
public abstract void enter(String namespace, String name, String comment) throws IOException;
public abstract void exit() throws IOException;
public abstract void exit(String name) throws IOException;
public abstract void exit(String namespace, String name) throws IOException;
public abstract void exitToLevel(int count) throws IOException;
public abstract void element(String namespace, String name, String content, boolean onlyIfNotEmpty) throws IOException;
public abstract void element(String namespace, String name, String content, String comment) throws IOException;
public abstract void element(String namespace, String name, String content) throws IOException;
public abstract void element(String name, String content, boolean onlyIfNotEmpty) throws IOException;
public abstract void element(String name, String content) throws IOException;
public abstract void element(String name) throws IOException;
public abstract void text(String content) throws IOException;
public abstract void text(String content, boolean dontEscape) throws IOException;
public abstract void cData(String text) throws IOException;
public abstract void writeBytes(byte[] bytes) throws IOException;
public abstract boolean isPretty() throws IOException;
public abstract void setPretty(boolean pretty) throws IOException;
/**
* Start comment inserts a <!-- in the stream, but allows the user to
* go on creating xml content as usual, with proper formatting applied etc.
* Any comments inserted inside a comment will be terminated with -- > instead of -->
* so the comment doesn't close prematurely.
* @throws IOException
*/
public abstract void startCommentBlock() throws IOException;
public abstract void endCommentBlock() throws IOException;
public abstract void escapedText(String content) throws IOException;
// this is only implemented by an implementation that is producing an xhtml representation, and is able to render elements as hyperlinks
public abstract void link(String href);
}

View File

@ -20,150 +20,150 @@ package org.hl7.fhir.utilities.xml;
* #L%
*/
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.utilities.TextStreamWriter;
import org.hl7.fhir.utilities.Utilities;
public class SchematronWriter extends TextStreamWriter {
public enum SchematronType {
ALL_RESOURCES,
RESOURCE,
PROFILE
}
public class Assert {
private String test;
private String message;
}
public class Rule {
private String name;
private List<Assert> asserts = new ArrayList<Assert>();
public void assrt(String test, String message) {
Assert a = new Assert();
a.test = test;
a.message = message;
asserts.add(a);
}
}
public class Section {
private String title;
private List<Rule> rules = new ArrayList<Rule>();
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Rule rule(String name) {
for (Rule r : rules) {
if (r.name.equals(name))
return r;
}
Rule r = new Rule();
r.name = name;
rules.add(r);
return r;
}
}
private SchematronType type;
private String description;
private List<Section> sections = new ArrayList<Section>();
public SchematronWriter(OutputStream out, SchematronType type, String description) throws UnsupportedEncodingException {
super(out);
this.type = type;
this.description = description;
}
public Section section(String title) {
for (Section s : sections) {
if (s.title.equals(title))
return s;
}
Section s = new Section();
s.title = title;
sections.add(s);
return s;
}
public void dump() throws IOException {
ln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
ln_i("<sch:schema xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" queryBinding=\"xslt2\">");
ln("<sch:ns prefix=\"f\" uri=\"http://hl7.org/fhir\"/>");
ln("<sch:ns prefix=\"h\" uri=\"http://www.w3.org/1999/xhtml\"/>");
addNote();
for (Section s : sections) {
ln_i("<sch:pattern>");
ln("<sch:title>"+s.title+"</sch:title>");
for (Rule r : s.rules) {
if (!r.asserts.isEmpty()) {
ln_i("<sch:rule context=\""+r.name+"\">");
for (Assert a : r.asserts)
ln("<sch:assert test=\""+Utilities.escapeXml(a.test)+"\">"+Utilities.escapeXml(a.message)+"</sch:assert>");
ln_o("</sch:rule>");
}
}
ln_o("</sch:pattern>");
}
ln_o("</sch:schema>");
flush();
close();
}
private void addNote() throws IOException {
switch (type) {
case ALL_RESOURCES : addAllResourcesNote(); break;
case RESOURCE : addResourceNote(); break;
case PROFILE : addProfileNote(); break;
}
}
private void addAllResourcesNote() throws IOException {
ln("<!-- ");
ln(" This file contains constraints for all resources");
ln(" Because of the way containment works, this file should always )");
ln(" be used for validating resources. Alternatively you can use ");
ln(" the resource specific files to build a smaller version of");
ln(" this file (the contents are identical; only include those ");
ln(" resources relevant to your implementation).");
ln("-->");
}
private void addResourceNote() throws IOException {
ln("<!-- ");
ln(" This file contains just the constraints for the resource "+description);
ln(" It is provided for documentation purposes. When actually validating,");
ln(" always use fhir-invariants.sch (because of the way containment works)");
ln(" Alternatively you can use this file to build a smaller version of");
ln(" fhir-invariants.sch (the contents are identical; only include those ");
ln(" resources relevant to your implementation).");
ln("-->");
}
private void addProfileNote() throws IOException {
ln("<!-- ");
ln(" This file contains just the constraints for the profile "+description);
ln(" It includes the base constraints for the resource as well.");
ln(" Because of the way that schematrons and containment work, ");
ln(" you may need to use this schematron fragment to build a, ");
ln(" single schematron that validates contained resources (if you have any) ");
ln("-->");
}
}
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.utilities.TextStreamWriter;
import org.hl7.fhir.utilities.Utilities;
public class SchematronWriter extends TextStreamWriter {
public enum SchematronType {
ALL_RESOURCES,
RESOURCE,
PROFILE
}
public class Assert {
private String test;
private String message;
}
public class Rule {
private String name;
private List<Assert> asserts = new ArrayList<Assert>();
public void assrt(String test, String message) {
Assert a = new Assert();
a.test = test;
a.message = message;
asserts.add(a);
}
}
public class Section {
private String title;
private List<Rule> rules = new ArrayList<Rule>();
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Rule rule(String name) {
for (Rule r : rules) {
if (r.name.equals(name))
return r;
}
Rule r = new Rule();
r.name = name;
rules.add(r);
return r;
}
}
private SchematronType type;
private String description;
private List<Section> sections = new ArrayList<Section>();
public SchematronWriter(OutputStream out, SchematronType type, String description) throws UnsupportedEncodingException {
super(out);
this.type = type;
this.description = description;
}
public Section section(String title) {
for (Section s : sections) {
if (s.title.equals(title))
return s;
}
Section s = new Section();
s.title = title;
sections.add(s);
return s;
}
public void dump() throws IOException {
ln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
ln_i("<sch:schema xmlns:sch=\"http://purl.oclc.org/dsdl/schematron\" queryBinding=\"xslt2\">");
ln("<sch:ns prefix=\"f\" uri=\"http://hl7.org/fhir\"/>");
ln("<sch:ns prefix=\"h\" uri=\"http://www.w3.org/1999/xhtml\"/>");
addNote();
for (Section s : sections) {
ln_i("<sch:pattern>");
ln("<sch:title>"+s.title+"</sch:title>");
for (Rule r : s.rules) {
if (!r.asserts.isEmpty()) {
ln_i("<sch:rule context=\""+r.name+"\">");
for (Assert a : r.asserts)
ln("<sch:assert test=\""+Utilities.escapeXml(a.test)+"\">"+Utilities.escapeXml(a.message)+"</sch:assert>");
ln_o("</sch:rule>");
}
}
ln_o("</sch:pattern>");
}
ln_o("</sch:schema>");
flush();
close();
}
private void addNote() throws IOException {
switch (type) {
case ALL_RESOURCES : addAllResourcesNote(); break;
case RESOURCE : addResourceNote(); break;
case PROFILE : addProfileNote(); break;
}
}
private void addAllResourcesNote() throws IOException {
ln("<!-- ");
ln(" This file contains constraints for all resources");
ln(" Because of the way containment works, this file should always )");
ln(" be used for validating resources. Alternatively you can use ");
ln(" the resource specific files to build a smaller version of");
ln(" this file (the contents are identical; only include those ");
ln(" resources relevant to your implementation).");
ln("-->");
}
private void addResourceNote() throws IOException {
ln("<!-- ");
ln(" This file contains just the constraints for the resource "+description);
ln(" It is provided for documentation purposes. When actually validating,");
ln(" always use fhir-invariants.sch (because of the way containment works)");
ln(" Alternatively you can use this file to build a smaller version of");
ln(" fhir-invariants.sch (the contents are identical; only include those ");
ln(" resources relevant to your implementation).");
ln("-->");
}
private void addProfileNote() throws IOException {
ln("<!-- ");
ln(" This file contains just the constraints for the profile "+description);
ln(" It includes the base constraints for the resource as well.");
ln(" Because of the way that schematrons and containment work, ");
ln(" you may need to use this schematron fragment to build a, ");
ln(" single schematron that validates contained resources (if you have any) ");
ln("-->");
}
}

View File

@ -1,32 +1,32 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xml;
/*
@ -49,32 +49,32 @@ package org.hl7.fhir.utilities.xml;
* #L%
*/
public class XMLNamespace {
private String namespace;
private String abbreviation;
public XMLNamespace(String namespace, String abbreviation) {
super();
setNamespace(namespace);
setAbbreviation(abbreviation);
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
}
public class XMLNamespace {
private String namespace;
private String abbreviation;
public XMLNamespace(String namespace, String abbreviation) {
super();
setNamespace(namespace);
setAbbreviation(abbreviation);
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xml;
/*
@ -48,441 +48,441 @@ package org.hl7.fhir.utilities.xml;
* #L%
*/
import java.io.*;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
import org.xml.sax.SAXException;
public class XMLUtil {
public static final String SPACE_CHAR = "\u00A0";
public static boolean isNMToken(String name) {
if (name == null)
return false;
for (int i = 0; i < name.length(); i++)
if (!isNMTokenChar(name.charAt(i)))
return false;
return name.length() > 0;
}
public static boolean isNMTokenChar(char c) {
return isLetter(c) || isDigit(c) || c == '.' || c == '-' || c == '_' || c == ':' || isCombiningChar(c) || isExtender(c);
}
private static boolean isDigit(char c) {
return (c >= '\u0030' && c <= '\u0039') || (c >= '\u0660' && c <= '\u0669') || (c >= '\u06F0' && c <= '\u06F9') ||
(c >= '\u0966' && c <= '\u096F') || (c >= '\u09E6' && c <= '\u09EF') || (c >= '\u0A66' && c <= '\u0A6F') ||
(c >= '\u0AE6' && c <= '\u0AEF') || (c >= '\u0B66' && c <= '\u0B6F') || (c >= '\u0BE7' && c <= '\u0BEF') ||
(c >= '\u0C66' && c <= '\u0C6F') || (c >= '\u0CE6' && c <= '\u0CEF') || (c >= '\u0D66' && c <= '\u0D6F') ||
(c >= '\u0E50' && c <= '\u0E59') || (c >= '\u0ED0' && c <= '\u0ED9') || (c >= '\u0F20' && c <= '\u0F29');
}
private static boolean isCombiningChar(char c) {
return (c >= '\u0300' && c <= '\u0345') || (c >= '\u0360' && c <= '\u0361') || (c >= '\u0483' && c <= '\u0486') ||
(c >= '\u0591' && c <= '\u05A1') || (c >= '\u05A3' && c <= '\u05B9') || (c >= '\u05BB' && c <= '\u05BD') ||
c == '\u05BF' || (c >= '\u05C1' && c <= '\u05C2') || c == '\u05C4' || (c >= '\u064B' && c <= '\u0652') ||
c == '\u0670' || (c >= '\u06D6' && c <= '\u06DC') || (c >= '\u06DD' && c <= '\u06DF') || (c >= '\u06E0' && c <= '\u06E4') ||
(c >= '\u06E7' && c <= '\u06E8') || (c >= '\u06EA' && c <= '\u06ED') || (c >= '\u0901' && c <= '\u0903') || c == '\u093C' ||
(c >= '\u093E' && c <= '\u094C') || c == '\u094D' || (c >= '\u0951' && c <= '\u0954') || (c >= '\u0962' && c <= '\u0963') ||
(c >= '\u0981' && c <= '\u0983') || c == '\u09BC' || c == '\u09BE' || c == '\u09BF' || (c >= '\u09C0' && c <= '\u09C4') ||
(c >= '\u09C7' && c <= '\u09C8') || (c >= '\u09CB' && c <= '\u09CD') || c == '\u09D7' || (c >= '\u09E2' && c <= '\u09E3') ||
c == '\u0A02' || c == '\u0A3C' || c == '\u0A3E' || c == '\u0A3F' || (c >= '\u0A40' && c <= '\u0A42') ||
(c >= '\u0A47' && c <= '\u0A48') || (c >= '\u0A4B' && c <= '\u0A4D') || (c >= '\u0A70' && c <= '\u0A71') ||
(c >= '\u0A81' && c <= '\u0A83') || c == '\u0ABC' || (c >= '\u0ABE' && c <= '\u0AC5') || (c >= '\u0AC7' && c <= '\u0AC9') ||
(c >= '\u0ACB' && c <= '\u0ACD') || (c >= '\u0B01' && c <= '\u0B03') || c == '\u0B3C' || (c >= '\u0B3E' && c <= '\u0B43') ||
(c >= '\u0B47' && c <= '\u0B48') || (c >= '\u0B4B' && c <= '\u0B4D') || (c >= '\u0B56' && c <= '\u0B57') ||
(c >= '\u0B82' && c <= '\u0B83') || (c >= '\u0BBE' && c <= '\u0BC2') || (c >= '\u0BC6' && c <= '\u0BC8') ||
(c >= '\u0BCA' && c <= '\u0BCD') || c == '\u0BD7' || (c >= '\u0C01' && c <= '\u0C03') || (c >= '\u0C3E' && c <= '\u0C44') ||
(c >= '\u0C46' && c <= '\u0C48') || (c >= '\u0C4A' && c <= '\u0C4D') || (c >= '\u0C55' && c <= '\u0C56') ||
(c >= '\u0C82' && c <= '\u0C83') || (c >= '\u0CBE' && c <= '\u0CC4') || (c >= '\u0CC6' && c <= '\u0CC8') ||
(c >= '\u0CCA' && c <= '\u0CCD') || (c >= '\u0CD5' && c <= '\u0CD6') || (c >= '\u0D02' && c <= '\u0D03') ||
(c >= '\u0D3E' && c <= '\u0D43') || (c >= '\u0D46' && c <= '\u0D48') || (c >= '\u0D4A' && c <= '\u0D4D') || c == '\u0D57' ||
c == '\u0E31' || (c >= '\u0E34' && c <= '\u0E3A') || (c >= '\u0E47' && c <= '\u0E4E') || c == '\u0EB1' ||
(c >= '\u0EB4' && c <= '\u0EB9') || (c >= '\u0EBB' && c <= '\u0EBC') || (c >= '\u0EC8' && c <= '\u0ECD') ||
(c >= '\u0F18' && c <= '\u0F19') || c == '\u0F35' || c == '\u0F37' || c == '\u0F39' || c == '\u0F3E' || c == '\u0F3F' ||
(c >= '\u0F71' && c <= '\u0F84') || (c >= '\u0F86' && c <= '\u0F8B') || (c >= '\u0F90' && c <= '\u0F95') || c == '\u0F97' ||
(c >= '\u0F99' && c <= '\u0FAD') || (c >= '\u0FB1' && c <= '\u0FB7') || c == '\u0FB9' || (c >= '\u20D0' && c <= '\u20DC') ||
c == '\u20E1' || (c >= '\u302A' && c <= '\u302F') || c == '\u3099' || c == '\u309A';
}
private static boolean isExtender(char c) {
return c == '\u00B7' || c == '\u02D0' || c == '\u02D1' || c == '\u0387' || c == '\u0640' || c == '\u0E46' ||
c == '\u0EC6' || c == '\u3005' || (c >= '\u3031' && c <= '\u3035') || (c >= '\u309D' && c <= '\u309E') ||
(c >= '\u30FC' && c <= '\u30FE');
}
private static boolean isLetter(char c) {
return isBaseChar(c) || isIdeographic(c);
}
private static boolean isBaseChar(char c) {
return (c >= '\u0041' && c <= '\u005A') || (c >= '\u0061' && c <= '\u007A') || (c >= '\u00C0' && c <= '\u00D6') ||
(c >= '\u00D8' && c <= '\u00F6') || (c >= '\u00F8' && c <= '\u00FF') || (c >= '\u0100' && c <= '\u0131') ||
(c >= '\u0134' && c <= '\u013E') || (c >= '\u0141' && c <= '\u0148') || (c >= '\u014A' && c <= '\u017E') ||
(c >= '\u0180' && c <= '\u01C3') || (c >= '\u01CD' && c <= '\u01F0') || (c >= '\u01F4' && c <= '\u01F5') ||
(c >= '\u01FA' && c <= '\u0217') || (c >= '\u0250' && c <= '\u02A8') || (c >= '\u02BB' && c <= '\u02C1') ||
c == '\u0386' || (c >= '\u0388' && c <= '\u038A') || c == '\u038C' || (c >= '\u038E' && c <= '\u03A1') ||
(c >= '\u03A3' && c <= '\u03CE') || (c >= '\u03D0' && c <= '\u03D6') || c == '\u03DA' || c == '\u03DC' || c == '\u03DE' ||
c == '\u03E0' || (c >= '\u03E2' && c <= '\u03F3') || (c >= '\u0401' && c <= '\u040C') || (c >= '\u040E' && c <= '\u044F') ||
(c >= '\u0451' && c <= '\u045C') || (c >= '\u045E' && c <= '\u0481') || (c >= '\u0490' && c <= '\u04C4') ||
(c >= '\u04C7' && c <= '\u04C8') || (c >= '\u04CB' && c <= '\u04CC') || (c >= '\u04D0' && c <= '\u04EB') ||
(c >= '\u04EE' && c <= '\u04F5') || (c >= '\u04F8' && c <= '\u04F9') || (c >= '\u0531' && c <= '\u0556') ||
c == '\u0559' || (c >= '\u0561' && c <= '\u0586') || (c >= '\u05D0' && c <= '\u05EA') || (c >= '\u05F0' && c <= '\u05F2') ||
(c >= '\u0621' && c <= '\u063A') || (c >= '\u0641' && c <= '\u064A') || (c >= '\u0671' && c <= '\u06B7') ||
(c >= '\u06BA' && c <= '\u06BE') || (c >= '\u06C0' && c <= '\u06CE') || (c >= '\u06D0' && c <= '\u06D3') ||
c == '\u06D5' || (c >= '\u06E5' && c <= '\u06E6') || (c >= '\u0905' && c <= '\u0939') || c == '\u093D' ||
(c >= '\u0958' && c <= '\u0961') || (c >= '\u0985' && c <= '\u098C') || (c >= '\u098F' && c <= '\u0990') ||
(c >= '\u0993' && c <= '\u09A8') || (c >= '\u09AA' && c <= '\u09B0') || c == '\u09B2' ||
(c >= '\u09B6' && c <= '\u09B9') || (c >= '\u09DC' && c <= '\u09DD') || (c >= '\u09DF' && c <= '\u09E1') ||
(c >= '\u09F0' && c <= '\u09F1') || (c >= '\u0A05' && c <= '\u0A0A') || (c >= '\u0A0F' && c <= '\u0A10') ||
(c >= '\u0A13' && c <= '\u0A28') || (c >= '\u0A2A' && c <= '\u0A30') || (c >= '\u0A32' && c <= '\u0A33') ||
(c >= '\u0A35' && c <= '\u0A36') || (c >= '\u0A38' && c <= '\u0A39') || (c >= '\u0A59' && c <= '\u0A5C') ||
c == '\u0A5E' || (c >= '\u0A72' && c <= '\u0A74') || (c >= '\u0A85' && c <= '\u0A8B') || c == '\u0A8D' ||
(c >= '\u0A8F' && c <= '\u0A91') || (c >= '\u0A93' && c <= '\u0AA8') || (c >= '\u0AAA' && c <= '\u0AB0') ||
(c >= '\u0AB2' && c <= '\u0AB3') || (c >= '\u0AB5' && c <= '\u0AB9') || c == '\u0ABD' || c == '\u0AE0' ||
(c >= '\u0B05' && c <= '\u0B0C') || (c >= '\u0B0F' && c <= '\u0B10') || (c >= '\u0B13' && c <= '\u0B28') ||
(c >= '\u0B2A' && c <= '\u0B30') || (c >= '\u0B32' && c <= '\u0B33') || (c >= '\u0B36' && c <= '\u0B39') ||
c == '\u0B3D' || (c >= '\u0B5C' && c <= '\u0B5D') || (c >= '\u0B5F' && c <= '\u0B61') ||
(c >= '\u0B85' && c <= '\u0B8A') || (c >= '\u0B8E' && c <= '\u0B90') || (c >= '\u0B92' && c <= '\u0B95') ||
(c >= '\u0B99' && c <= '\u0B9A') || c == '\u0B9C' || (c >= '\u0B9E' && c <= '\u0B9F') ||
(c >= '\u0BA3' && c <= '\u0BA4') || (c >= '\u0BA8' && c <= '\u0BAA') || (c >= '\u0BAE' && c <= '\u0BB5') ||
(c >= '\u0BB7' && c <= '\u0BB9') || (c >= '\u0C05' && c <= '\u0C0C') || (c >= '\u0C0E' && c <= '\u0C10') ||
(c >= '\u0C12' && c <= '\u0C28') || (c >= '\u0C2A' && c <= '\u0C33') || (c >= '\u0C35' && c <= '\u0C39') ||
(c >= '\u0C60' && c <= '\u0C61') || (c >= '\u0C85' && c <= '\u0C8C') || (c >= '\u0C8E' && c <= '\u0C90') ||
(c >= '\u0C92' && c <= '\u0CA8') || (c >= '\u0CAA' && c <= '\u0CB3') || (c >= '\u0CB5' && c <= '\u0CB9') ||
c == '\u0CDE' || (c >= '\u0CE0' && c <= '\u0CE1') || (c >= '\u0D05' && c <= '\u0D0C') ||
(c >= '\u0D0E' && c <= '\u0D10') || (c >= '\u0D12' && c <= '\u0D28') || (c >= '\u0D2A' && c <= '\u0D39') ||
(c >= '\u0D60' && c <= '\u0D61') || (c >= '\u0E01' && c <= '\u0E2E') || c == '\u0E30' ||
(c >= '\u0E32' && c <= '\u0E33') || (c >= '\u0E40' && c <= '\u0E45') || (c >= '\u0E81' && c <= '\u0E82') ||
c == '\u0E84' || (c >= '\u0E87' && c <= '\u0E88') || c == '\u0E8A' || c == '\u0E8D' || (c >= '\u0E94' && c <= '\u0E97') ||
(c >= '\u0E99' && c <= '\u0E9F') || (c >= '\u0EA1' && c <= '\u0EA3') || c == '\u0EA5' || c == '\u0EA7' ||
(c >= '\u0EAA' && c <= '\u0EAB') || (c >= '\u0EAD' && c <= '\u0EAE') || c == '\u0EB0' ||
(c >= '\u0EB2' && c <= '\u0EB3') || c == '\u0EBD' || (c >= '\u0EC0' && c <= '\u0EC4') ||
(c >= '\u0F40' && c <= '\u0F47') || (c >= '\u0F49' && c <= '\u0F69') || (c >= '\u10A0' && c <= '\u10C5') ||
(c >= '\u10D0' && c <= '\u10F6') || c == '\u1100' || (c >= '\u1102' && c <= '\u1103') ||
(c >= '\u1105' && c <= '\u1107') || c == '\u1109' || (c >= '\u110B' && c <= '\u110C') ||
(c >= '\u110E' && c <= '\u1112') || c == '\u113C' || c == '\u113E' || c == '\u1140' || c == '\u114C' ||
c == '\u114E' || c == '\u1150' || (c >= '\u1154' && c <= '\u1155') || c == '\u1159' ||
(c >= '\u115F' && c <= '\u1161') || c == '\u1163' || c == '\u1165' || c == '\u1167' || c == '\u1169' ||
(c >= '\u116D' && c <= '\u116E') || (c >= '\u1172' && c <= '\u1173') || c == '\u1175' ||
c == '\u119E' || c == '\u11A8' || c == '\u11AB' || (c >= '\u11AE' && c <= '\u11AF') ||
(c >= '\u11B7' && c <= '\u11B8') || c == '\u11BA' || (c >= '\u11BC' && c <= '\u11C2') ||
c == '\u11EB' || c == '\u11F0' || c == '\u11F9' || (c >= '\u1E00' && c <= '\u1E9B') || (c >= '\u1EA0' && c <= '\u1EF9') ||
(c >= '\u1F00' && c <= '\u1F15') || (c >= '\u1F18' && c <= '\u1F1D') || (c >= '\u1F20' && c <= '\u1F45') ||
(c >= '\u1F48' && c <= '\u1F4D') || (c >= '\u1F50' && c <= '\u1F57') || c == '\u1F59' || c == '\u1F5B' || c == '\u1F5D' ||
(c >= '\u1F5F' && c <= '\u1F7D') || (c >= '\u1F80' && c <= '\u1FB4') || (c >= '\u1FB6' && c <= '\u1FBC') ||
c == '\u1FBE' || (c >= '\u1FC2' && c <= '\u1FC4') || (c >= '\u1FC6' && c <= '\u1FCC') ||
(c >= '\u1FD0' && c <= '\u1FD3') || (c >= '\u1FD6' && c <= '\u1FDB') || (c >= '\u1FE0' && c <= '\u1FEC') ||
(c >= '\u1FF2' && c <= '\u1FF4') || (c >= '\u1FF6' && c <= '\u1FFC') || c == '\u2126' ||
(c >= '\u212A' && c <= '\u212B') || c == '\u212E' || (c >= '\u2180' && c <= '\u2182') ||
(c >= '\u3041' && c <= '\u3094') || (c >= '\u30A1' && c <= '\u30FA') || (c >= '\u3105' && c <= '\u312C') ||
(c >= '\uAC00' && c <= '\uD7A3');
}
private static boolean isIdeographic(char c) {
return (c >= '\u4E00' && c <= '\u9FA5') || c == '\u3007' || (c >= '\u3021' && c <= '\u3029');
}
public static String determineEncoding(InputStream stream) throws IOException {
stream.mark(20000);
try {
int b0 = stream.read();
int b1 = stream.read();
int b2 = stream.read();
int b3 = stream.read();
if (b0 == 0xFE && b1 == 0xFF)
return "UTF-16BE";
else if (b0 == 0xFF && b1 == 0xFE)
return "UTF-16LE";
else if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF )
return "UTF-8";
else if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F)
return "UTF-16BE";
else if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00)
return "UTF-16LE";
else if (b0 == 0x3C && b1 == 0x3F && b2 == 0x78 && b3 == 0x6D) {
// UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other 7-bit, 8-bit, or mixed-width encoding
// which ensures that the characters of ASCII have their normal positions, width, and values; the actual encoding
// declaration must be read to detect which of these applies, but since all of these encodings use the same bit patterns
// for the relevant ASCII characters, the encoding declaration itself may be read reliably
InputStreamReader rdr = new InputStreamReader(stream, "US-ASCII");
String hdr = readFirstLine(rdr);
return extractEncoding(hdr);
} else
return null;
} finally {
stream.reset();
}
}
private static String extractEncoding(String hdr) {
int i = hdr.indexOf("encoding=");
if (i == -1)
return null;
hdr = hdr.substring(i+9);
char sep = hdr.charAt(0);
hdr = hdr.substring(1);
i = hdr.indexOf(sep);
if (i == -1)
return null;
return hdr.substring(0, i);
}
private static String readFirstLine(InputStreamReader rdr) throws IOException {
char[] buf = new char[1];
StringBuffer bldr = new StringBuffer();
rdr.read(buf);
while (buf[0] != '>') {
bldr.append(buf[0]);
rdr.read(buf);
}
return bldr.toString();
}
public static boolean charSetImpliesAscii(String charset) {
return charset.equals("ISO-8859-1") || charset.equals("US-ASCII");
}
/**
* Converts the raw characters to XML escape characters.
*
* @param rawContent
* @param charset Null when charset is not known, so we assume it's unicode
* @param isNoLines
* @return escape string
*/
public static String escapeXML(String rawContent, String charset, boolean isNoLines) {
if (rawContent == null)
return "";
else {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < rawContent.length(); i++) {
char ch = rawContent.charAt(i);
if (ch == '\'')
sb.append("&#39;");
else if (ch == '&')
sb.append("&amp;");
else if (ch == '"')
sb.append("&quot;");
else if (ch == '<')
sb.append("&lt;");
else if (ch == '>')
sb.append("&gt;");
else if (ch > '~' && charset != null && charSetImpliesAscii(charset))
// TODO - why is hashcode the only way to get the unicode number for the character
// in jre 5.0?
sb.append("&#x"+Integer.toHexString(new Character(ch).hashCode()).toUpperCase()+";");
else if (isNoLines) {
if (ch == '\r')
sb.append("&#xA;");
else if (ch != '\n')
sb.append(ch);
}
else
sb.append(ch);
}
return sb.toString();
}
}
public static Element getFirstChild(Element e) {
if (e == null)
return null;
Node n = e.getFirstChild();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getNextSibling();
return (Element) n;
}
public static Element getNamedChild(Element e, String name) {
Element c = getFirstChild(e);
while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName()))
c = getNextSibling(c);
return c;
}
public static Element getNextSibling(Element e) {
Node n = e.getNextSibling();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getNextSibling();
return (Element) n;
}
public static void getNamedChildren(Element e, String name, List<Element> set) {
Element c = getFirstChild(e);
while (c != null) {
if (name.equals(c.getLocalName()) || name.equals(c.getNodeName()) )
set.add(c);
c = getNextSibling(c);
}
}
public static String htmlToXmlEscapedPlainText(Element r) {
StringBuilder s = new StringBuilder();
Node n = r.getFirstChild();
boolean ws = false;
while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE) {
String t = n.getTextContent().trim();
if (Utilities.noString(t))
ws = true;
else {
if (ws)
s.append(" ");
ws = false;
s.append(t);
}
}
if (n.getNodeType() == Node.ELEMENT_NODE) {
if (ws)
s.append(" ");
ws = false;
s.append(htmlToXmlEscapedPlainText((Element) n));
if (r.getNodeName().equals("br") || r.getNodeName().equals("p"))
s.append("\r\n");
}
n = n.getNextSibling();
}
return s.toString();
}
public static String htmlToXmlEscapedPlainText(String definition) throws ParserConfigurationException, SAXException, IOException {
return htmlToXmlEscapedPlainText(parseToDom("<div>"+definition+"</div>").getDocumentElement());
}
public static String elementToString(Element el) {
if (el == null)
return "";
Document document = el.getOwnerDocument();
DOMImplementationLS domImplLS = (DOMImplementationLS) document
.getImplementation();
LSSerializer serializer = domImplLS.createLSSerializer();
return serializer.writeToString(el);
}
public static String getNamedChildValue(Element element, String name) {
Element e = getNamedChild(element, name);
return e == null ? null : e.getAttribute("value");
}
public static void setNamedChildValue(Element element, String name, String value) throws FHIRException {
Element e = getNamedChild(element, name);
if (e == null)
throw new FHIRException("unable to find element "+name);
e.setAttribute("value", value);
}
public static void getNamedChildrenWithWildcard(Element focus, String name, List<Element> children) {
Element c = getFirstChild(focus);
while (c != null) {
String n = c.getLocalName() != null ? c.getLocalName() : c.getNodeName();
if (name.equals(n) || (name.endsWith("[x]") && n.startsWith(name.substring(0, name.length()-3))))
children.add(c);
c = getNextSibling(c);
}
}
public static void getNamedChildrenWithTails(Element focus, String name, List<Element> children, Set<String> typeTails) {
Element c = getFirstChild(focus);
while (c != null) {
String n = c.getLocalName() != null ? c.getLocalName() : c.getNodeName();
if (n.equals(name) || (!n.equals("responseCode") && (n.startsWith(name) && typeTails.contains(n.substring(name.length())))))
children.add(c);
c = getNextSibling(c);
}
}
public static boolean hasNamedChild(Element e, String name) {
Element c = getFirstChild(e);
while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName()))
c = getNextSibling(c);
return c != null;
}
public static Document parseToDom(String content) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(content.getBytes()));
}
public static Document parseFileToDom(String filename) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new FileInputStream(filename));
}
public static Element getLastChild(Element e) {
if (e == null)
return null;
Node n = e.getLastChild();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getPreviousSibling();
return (Element) n;
}
public static Element getPrevSibling(Element e) {
Node n = e.getPreviousSibling();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getPreviousSibling();
return (Element) n;
}
public static String getNamedChildAttribute(Element element, String name, String aname) {
Element e = getNamedChild(element, name);
return e == null ? null : e.getAttribute(aname);
}
public static void writeDomToFile(Document doc, String filename) throws TransformerException {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult streamResult = new StreamResult(new File(filename));
transformer.transform(source, streamResult);
}
public static String getXsiType(org.w3c.dom.Element element) {
Attr a = element.getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "type");
return (a == null ? null : a.getTextContent());
}
public static String getDirectText(org.w3c.dom.Element node) {
Node n = node.getFirstChild();
StringBuilder b = new StringBuilder();
while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE)
b.append(n.getTextContent());
n = n.getNextSibling();
}
return b.toString().trim();
}
}
import java.io.*;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.utilities.Utilities;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
import org.xml.sax.SAXException;
public class XMLUtil {
public static final String SPACE_CHAR = "\u00A0";
public static boolean isNMToken(String name) {
if (name == null)
return false;
for (int i = 0; i < name.length(); i++)
if (!isNMTokenChar(name.charAt(i)))
return false;
return name.length() > 0;
}
public static boolean isNMTokenChar(char c) {
return isLetter(c) || isDigit(c) || c == '.' || c == '-' || c == '_' || c == ':' || isCombiningChar(c) || isExtender(c);
}
private static boolean isDigit(char c) {
return (c >= '\u0030' && c <= '\u0039') || (c >= '\u0660' && c <= '\u0669') || (c >= '\u06F0' && c <= '\u06F9') ||
(c >= '\u0966' && c <= '\u096F') || (c >= '\u09E6' && c <= '\u09EF') || (c >= '\u0A66' && c <= '\u0A6F') ||
(c >= '\u0AE6' && c <= '\u0AEF') || (c >= '\u0B66' && c <= '\u0B6F') || (c >= '\u0BE7' && c <= '\u0BEF') ||
(c >= '\u0C66' && c <= '\u0C6F') || (c >= '\u0CE6' && c <= '\u0CEF') || (c >= '\u0D66' && c <= '\u0D6F') ||
(c >= '\u0E50' && c <= '\u0E59') || (c >= '\u0ED0' && c <= '\u0ED9') || (c >= '\u0F20' && c <= '\u0F29');
}
private static boolean isCombiningChar(char c) {
return (c >= '\u0300' && c <= '\u0345') || (c >= '\u0360' && c <= '\u0361') || (c >= '\u0483' && c <= '\u0486') ||
(c >= '\u0591' && c <= '\u05A1') || (c >= '\u05A3' && c <= '\u05B9') || (c >= '\u05BB' && c <= '\u05BD') ||
c == '\u05BF' || (c >= '\u05C1' && c <= '\u05C2') || c == '\u05C4' || (c >= '\u064B' && c <= '\u0652') ||
c == '\u0670' || (c >= '\u06D6' && c <= '\u06DC') || (c >= '\u06DD' && c <= '\u06DF') || (c >= '\u06E0' && c <= '\u06E4') ||
(c >= '\u06E7' && c <= '\u06E8') || (c >= '\u06EA' && c <= '\u06ED') || (c >= '\u0901' && c <= '\u0903') || c == '\u093C' ||
(c >= '\u093E' && c <= '\u094C') || c == '\u094D' || (c >= '\u0951' && c <= '\u0954') || (c >= '\u0962' && c <= '\u0963') ||
(c >= '\u0981' && c <= '\u0983') || c == '\u09BC' || c == '\u09BE' || c == '\u09BF' || (c >= '\u09C0' && c <= '\u09C4') ||
(c >= '\u09C7' && c <= '\u09C8') || (c >= '\u09CB' && c <= '\u09CD') || c == '\u09D7' || (c >= '\u09E2' && c <= '\u09E3') ||
c == '\u0A02' || c == '\u0A3C' || c == '\u0A3E' || c == '\u0A3F' || (c >= '\u0A40' && c <= '\u0A42') ||
(c >= '\u0A47' && c <= '\u0A48') || (c >= '\u0A4B' && c <= '\u0A4D') || (c >= '\u0A70' && c <= '\u0A71') ||
(c >= '\u0A81' && c <= '\u0A83') || c == '\u0ABC' || (c >= '\u0ABE' && c <= '\u0AC5') || (c >= '\u0AC7' && c <= '\u0AC9') ||
(c >= '\u0ACB' && c <= '\u0ACD') || (c >= '\u0B01' && c <= '\u0B03') || c == '\u0B3C' || (c >= '\u0B3E' && c <= '\u0B43') ||
(c >= '\u0B47' && c <= '\u0B48') || (c >= '\u0B4B' && c <= '\u0B4D') || (c >= '\u0B56' && c <= '\u0B57') ||
(c >= '\u0B82' && c <= '\u0B83') || (c >= '\u0BBE' && c <= '\u0BC2') || (c >= '\u0BC6' && c <= '\u0BC8') ||
(c >= '\u0BCA' && c <= '\u0BCD') || c == '\u0BD7' || (c >= '\u0C01' && c <= '\u0C03') || (c >= '\u0C3E' && c <= '\u0C44') ||
(c >= '\u0C46' && c <= '\u0C48') || (c >= '\u0C4A' && c <= '\u0C4D') || (c >= '\u0C55' && c <= '\u0C56') ||
(c >= '\u0C82' && c <= '\u0C83') || (c >= '\u0CBE' && c <= '\u0CC4') || (c >= '\u0CC6' && c <= '\u0CC8') ||
(c >= '\u0CCA' && c <= '\u0CCD') || (c >= '\u0CD5' && c <= '\u0CD6') || (c >= '\u0D02' && c <= '\u0D03') ||
(c >= '\u0D3E' && c <= '\u0D43') || (c >= '\u0D46' && c <= '\u0D48') || (c >= '\u0D4A' && c <= '\u0D4D') || c == '\u0D57' ||
c == '\u0E31' || (c >= '\u0E34' && c <= '\u0E3A') || (c >= '\u0E47' && c <= '\u0E4E') || c == '\u0EB1' ||
(c >= '\u0EB4' && c <= '\u0EB9') || (c >= '\u0EBB' && c <= '\u0EBC') || (c >= '\u0EC8' && c <= '\u0ECD') ||
(c >= '\u0F18' && c <= '\u0F19') || c == '\u0F35' || c == '\u0F37' || c == '\u0F39' || c == '\u0F3E' || c == '\u0F3F' ||
(c >= '\u0F71' && c <= '\u0F84') || (c >= '\u0F86' && c <= '\u0F8B') || (c >= '\u0F90' && c <= '\u0F95') || c == '\u0F97' ||
(c >= '\u0F99' && c <= '\u0FAD') || (c >= '\u0FB1' && c <= '\u0FB7') || c == '\u0FB9' || (c >= '\u20D0' && c <= '\u20DC') ||
c == '\u20E1' || (c >= '\u302A' && c <= '\u302F') || c == '\u3099' || c == '\u309A';
}
private static boolean isExtender(char c) {
return c == '\u00B7' || c == '\u02D0' || c == '\u02D1' || c == '\u0387' || c == '\u0640' || c == '\u0E46' ||
c == '\u0EC6' || c == '\u3005' || (c >= '\u3031' && c <= '\u3035') || (c >= '\u309D' && c <= '\u309E') ||
(c >= '\u30FC' && c <= '\u30FE');
}
private static boolean isLetter(char c) {
return isBaseChar(c) || isIdeographic(c);
}
private static boolean isBaseChar(char c) {
return (c >= '\u0041' && c <= '\u005A') || (c >= '\u0061' && c <= '\u007A') || (c >= '\u00C0' && c <= '\u00D6') ||
(c >= '\u00D8' && c <= '\u00F6') || (c >= '\u00F8' && c <= '\u00FF') || (c >= '\u0100' && c <= '\u0131') ||
(c >= '\u0134' && c <= '\u013E') || (c >= '\u0141' && c <= '\u0148') || (c >= '\u014A' && c <= '\u017E') ||
(c >= '\u0180' && c <= '\u01C3') || (c >= '\u01CD' && c <= '\u01F0') || (c >= '\u01F4' && c <= '\u01F5') ||
(c >= '\u01FA' && c <= '\u0217') || (c >= '\u0250' && c <= '\u02A8') || (c >= '\u02BB' && c <= '\u02C1') ||
c == '\u0386' || (c >= '\u0388' && c <= '\u038A') || c == '\u038C' || (c >= '\u038E' && c <= '\u03A1') ||
(c >= '\u03A3' && c <= '\u03CE') || (c >= '\u03D0' && c <= '\u03D6') || c == '\u03DA' || c == '\u03DC' || c == '\u03DE' ||
c == '\u03E0' || (c >= '\u03E2' && c <= '\u03F3') || (c >= '\u0401' && c <= '\u040C') || (c >= '\u040E' && c <= '\u044F') ||
(c >= '\u0451' && c <= '\u045C') || (c >= '\u045E' && c <= '\u0481') || (c >= '\u0490' && c <= '\u04C4') ||
(c >= '\u04C7' && c <= '\u04C8') || (c >= '\u04CB' && c <= '\u04CC') || (c >= '\u04D0' && c <= '\u04EB') ||
(c >= '\u04EE' && c <= '\u04F5') || (c >= '\u04F8' && c <= '\u04F9') || (c >= '\u0531' && c <= '\u0556') ||
c == '\u0559' || (c >= '\u0561' && c <= '\u0586') || (c >= '\u05D0' && c <= '\u05EA') || (c >= '\u05F0' && c <= '\u05F2') ||
(c >= '\u0621' && c <= '\u063A') || (c >= '\u0641' && c <= '\u064A') || (c >= '\u0671' && c <= '\u06B7') ||
(c >= '\u06BA' && c <= '\u06BE') || (c >= '\u06C0' && c <= '\u06CE') || (c >= '\u06D0' && c <= '\u06D3') ||
c == '\u06D5' || (c >= '\u06E5' && c <= '\u06E6') || (c >= '\u0905' && c <= '\u0939') || c == '\u093D' ||
(c >= '\u0958' && c <= '\u0961') || (c >= '\u0985' && c <= '\u098C') || (c >= '\u098F' && c <= '\u0990') ||
(c >= '\u0993' && c <= '\u09A8') || (c >= '\u09AA' && c <= '\u09B0') || c == '\u09B2' ||
(c >= '\u09B6' && c <= '\u09B9') || (c >= '\u09DC' && c <= '\u09DD') || (c >= '\u09DF' && c <= '\u09E1') ||
(c >= '\u09F0' && c <= '\u09F1') || (c >= '\u0A05' && c <= '\u0A0A') || (c >= '\u0A0F' && c <= '\u0A10') ||
(c >= '\u0A13' && c <= '\u0A28') || (c >= '\u0A2A' && c <= '\u0A30') || (c >= '\u0A32' && c <= '\u0A33') ||
(c >= '\u0A35' && c <= '\u0A36') || (c >= '\u0A38' && c <= '\u0A39') || (c >= '\u0A59' && c <= '\u0A5C') ||
c == '\u0A5E' || (c >= '\u0A72' && c <= '\u0A74') || (c >= '\u0A85' && c <= '\u0A8B') || c == '\u0A8D' ||
(c >= '\u0A8F' && c <= '\u0A91') || (c >= '\u0A93' && c <= '\u0AA8') || (c >= '\u0AAA' && c <= '\u0AB0') ||
(c >= '\u0AB2' && c <= '\u0AB3') || (c >= '\u0AB5' && c <= '\u0AB9') || c == '\u0ABD' || c == '\u0AE0' ||
(c >= '\u0B05' && c <= '\u0B0C') || (c >= '\u0B0F' && c <= '\u0B10') || (c >= '\u0B13' && c <= '\u0B28') ||
(c >= '\u0B2A' && c <= '\u0B30') || (c >= '\u0B32' && c <= '\u0B33') || (c >= '\u0B36' && c <= '\u0B39') ||
c == '\u0B3D' || (c >= '\u0B5C' && c <= '\u0B5D') || (c >= '\u0B5F' && c <= '\u0B61') ||
(c >= '\u0B85' && c <= '\u0B8A') || (c >= '\u0B8E' && c <= '\u0B90') || (c >= '\u0B92' && c <= '\u0B95') ||
(c >= '\u0B99' && c <= '\u0B9A') || c == '\u0B9C' || (c >= '\u0B9E' && c <= '\u0B9F') ||
(c >= '\u0BA3' && c <= '\u0BA4') || (c >= '\u0BA8' && c <= '\u0BAA') || (c >= '\u0BAE' && c <= '\u0BB5') ||
(c >= '\u0BB7' && c <= '\u0BB9') || (c >= '\u0C05' && c <= '\u0C0C') || (c >= '\u0C0E' && c <= '\u0C10') ||
(c >= '\u0C12' && c <= '\u0C28') || (c >= '\u0C2A' && c <= '\u0C33') || (c >= '\u0C35' && c <= '\u0C39') ||
(c >= '\u0C60' && c <= '\u0C61') || (c >= '\u0C85' && c <= '\u0C8C') || (c >= '\u0C8E' && c <= '\u0C90') ||
(c >= '\u0C92' && c <= '\u0CA8') || (c >= '\u0CAA' && c <= '\u0CB3') || (c >= '\u0CB5' && c <= '\u0CB9') ||
c == '\u0CDE' || (c >= '\u0CE0' && c <= '\u0CE1') || (c >= '\u0D05' && c <= '\u0D0C') ||
(c >= '\u0D0E' && c <= '\u0D10') || (c >= '\u0D12' && c <= '\u0D28') || (c >= '\u0D2A' && c <= '\u0D39') ||
(c >= '\u0D60' && c <= '\u0D61') || (c >= '\u0E01' && c <= '\u0E2E') || c == '\u0E30' ||
(c >= '\u0E32' && c <= '\u0E33') || (c >= '\u0E40' && c <= '\u0E45') || (c >= '\u0E81' && c <= '\u0E82') ||
c == '\u0E84' || (c >= '\u0E87' && c <= '\u0E88') || c == '\u0E8A' || c == '\u0E8D' || (c >= '\u0E94' && c <= '\u0E97') ||
(c >= '\u0E99' && c <= '\u0E9F') || (c >= '\u0EA1' && c <= '\u0EA3') || c == '\u0EA5' || c == '\u0EA7' ||
(c >= '\u0EAA' && c <= '\u0EAB') || (c >= '\u0EAD' && c <= '\u0EAE') || c == '\u0EB0' ||
(c >= '\u0EB2' && c <= '\u0EB3') || c == '\u0EBD' || (c >= '\u0EC0' && c <= '\u0EC4') ||
(c >= '\u0F40' && c <= '\u0F47') || (c >= '\u0F49' && c <= '\u0F69') || (c >= '\u10A0' && c <= '\u10C5') ||
(c >= '\u10D0' && c <= '\u10F6') || c == '\u1100' || (c >= '\u1102' && c <= '\u1103') ||
(c >= '\u1105' && c <= '\u1107') || c == '\u1109' || (c >= '\u110B' && c <= '\u110C') ||
(c >= '\u110E' && c <= '\u1112') || c == '\u113C' || c == '\u113E' || c == '\u1140' || c == '\u114C' ||
c == '\u114E' || c == '\u1150' || (c >= '\u1154' && c <= '\u1155') || c == '\u1159' ||
(c >= '\u115F' && c <= '\u1161') || c == '\u1163' || c == '\u1165' || c == '\u1167' || c == '\u1169' ||
(c >= '\u116D' && c <= '\u116E') || (c >= '\u1172' && c <= '\u1173') || c == '\u1175' ||
c == '\u119E' || c == '\u11A8' || c == '\u11AB' || (c >= '\u11AE' && c <= '\u11AF') ||
(c >= '\u11B7' && c <= '\u11B8') || c == '\u11BA' || (c >= '\u11BC' && c <= '\u11C2') ||
c == '\u11EB' || c == '\u11F0' || c == '\u11F9' || (c >= '\u1E00' && c <= '\u1E9B') || (c >= '\u1EA0' && c <= '\u1EF9') ||
(c >= '\u1F00' && c <= '\u1F15') || (c >= '\u1F18' && c <= '\u1F1D') || (c >= '\u1F20' && c <= '\u1F45') ||
(c >= '\u1F48' && c <= '\u1F4D') || (c >= '\u1F50' && c <= '\u1F57') || c == '\u1F59' || c == '\u1F5B' || c == '\u1F5D' ||
(c >= '\u1F5F' && c <= '\u1F7D') || (c >= '\u1F80' && c <= '\u1FB4') || (c >= '\u1FB6' && c <= '\u1FBC') ||
c == '\u1FBE' || (c >= '\u1FC2' && c <= '\u1FC4') || (c >= '\u1FC6' && c <= '\u1FCC') ||
(c >= '\u1FD0' && c <= '\u1FD3') || (c >= '\u1FD6' && c <= '\u1FDB') || (c >= '\u1FE0' && c <= '\u1FEC') ||
(c >= '\u1FF2' && c <= '\u1FF4') || (c >= '\u1FF6' && c <= '\u1FFC') || c == '\u2126' ||
(c >= '\u212A' && c <= '\u212B') || c == '\u212E' || (c >= '\u2180' && c <= '\u2182') ||
(c >= '\u3041' && c <= '\u3094') || (c >= '\u30A1' && c <= '\u30FA') || (c >= '\u3105' && c <= '\u312C') ||
(c >= '\uAC00' && c <= '\uD7A3');
}
private static boolean isIdeographic(char c) {
return (c >= '\u4E00' && c <= '\u9FA5') || c == '\u3007' || (c >= '\u3021' && c <= '\u3029');
}
public static String determineEncoding(InputStream stream) throws IOException {
stream.mark(20000);
try {
int b0 = stream.read();
int b1 = stream.read();
int b2 = stream.read();
int b3 = stream.read();
if (b0 == 0xFE && b1 == 0xFF)
return "UTF-16BE";
else if (b0 == 0xFF && b1 == 0xFE)
return "UTF-16LE";
else if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF )
return "UTF-8";
else if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F)
return "UTF-16BE";
else if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00)
return "UTF-16LE";
else if (b0 == 0x3C && b1 == 0x3F && b2 == 0x78 && b3 == 0x6D) {
// UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other 7-bit, 8-bit, or mixed-width encoding
// which ensures that the characters of ASCII have their normal positions, width, and values; the actual encoding
// declaration must be read to detect which of these applies, but since all of these encodings use the same bit patterns
// for the relevant ASCII characters, the encoding declaration itself may be read reliably
InputStreamReader rdr = new InputStreamReader(stream, "US-ASCII");
String hdr = readFirstLine(rdr);
return extractEncoding(hdr);
} else
return null;
} finally {
stream.reset();
}
}
private static String extractEncoding(String hdr) {
int i = hdr.indexOf("encoding=");
if (i == -1)
return null;
hdr = hdr.substring(i+9);
char sep = hdr.charAt(0);
hdr = hdr.substring(1);
i = hdr.indexOf(sep);
if (i == -1)
return null;
return hdr.substring(0, i);
}
private static String readFirstLine(InputStreamReader rdr) throws IOException {
char[] buf = new char[1];
StringBuffer bldr = new StringBuffer();
rdr.read(buf);
while (buf[0] != '>') {
bldr.append(buf[0]);
rdr.read(buf);
}
return bldr.toString();
}
public static boolean charSetImpliesAscii(String charset) {
return charset.equals("ISO-8859-1") || charset.equals("US-ASCII");
}
/**
* Converts the raw characters to XML escape characters.
*
* @param rawContent
* @param charset Null when charset is not known, so we assume it's unicode
* @param isNoLines
* @return escape string
*/
public static String escapeXML(String rawContent, String charset, boolean isNoLines) {
if (rawContent == null)
return "";
else {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < rawContent.length(); i++) {
char ch = rawContent.charAt(i);
if (ch == '\'')
sb.append("&#39;");
else if (ch == '&')
sb.append("&amp;");
else if (ch == '"')
sb.append("&quot;");
else if (ch == '<')
sb.append("&lt;");
else if (ch == '>')
sb.append("&gt;");
else if (ch > '~' && charset != null && charSetImpliesAscii(charset))
// TODO - why is hashcode the only way to get the unicode number for the character
// in jre 5.0?
sb.append("&#x"+Integer.toHexString(new Character(ch).hashCode()).toUpperCase()+";");
else if (isNoLines) {
if (ch == '\r')
sb.append("&#xA;");
else if (ch != '\n')
sb.append(ch);
}
else
sb.append(ch);
}
return sb.toString();
}
}
public static Element getFirstChild(Element e) {
if (e == null)
return null;
Node n = e.getFirstChild();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getNextSibling();
return (Element) n;
}
public static Element getNamedChild(Element e, String name) {
Element c = getFirstChild(e);
while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName()))
c = getNextSibling(c);
return c;
}
public static Element getNextSibling(Element e) {
Node n = e.getNextSibling();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getNextSibling();
return (Element) n;
}
public static void getNamedChildren(Element e, String name, List<Element> set) {
Element c = getFirstChild(e);
while (c != null) {
if (name.equals(c.getLocalName()) || name.equals(c.getNodeName()) )
set.add(c);
c = getNextSibling(c);
}
}
public static String htmlToXmlEscapedPlainText(Element r) {
StringBuilder s = new StringBuilder();
Node n = r.getFirstChild();
boolean ws = false;
while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE) {
String t = n.getTextContent().trim();
if (Utilities.noString(t))
ws = true;
else {
if (ws)
s.append(" ");
ws = false;
s.append(t);
}
}
if (n.getNodeType() == Node.ELEMENT_NODE) {
if (ws)
s.append(" ");
ws = false;
s.append(htmlToXmlEscapedPlainText((Element) n));
if (r.getNodeName().equals("br") || r.getNodeName().equals("p"))
s.append("\r\n");
}
n = n.getNextSibling();
}
return s.toString();
}
public static String htmlToXmlEscapedPlainText(String definition) throws ParserConfigurationException, SAXException, IOException {
return htmlToXmlEscapedPlainText(parseToDom("<div>"+definition+"</div>").getDocumentElement());
}
public static String elementToString(Element el) {
if (el == null)
return "";
Document document = el.getOwnerDocument();
DOMImplementationLS domImplLS = (DOMImplementationLS) document
.getImplementation();
LSSerializer serializer = domImplLS.createLSSerializer();
return serializer.writeToString(el);
}
public static String getNamedChildValue(Element element, String name) {
Element e = getNamedChild(element, name);
return e == null ? null : e.getAttribute("value");
}
public static void setNamedChildValue(Element element, String name, String value) throws FHIRException {
Element e = getNamedChild(element, name);
if (e == null)
throw new FHIRException("unable to find element "+name);
e.setAttribute("value", value);
}
public static void getNamedChildrenWithWildcard(Element focus, String name, List<Element> children) {
Element c = getFirstChild(focus);
while (c != null) {
String n = c.getLocalName() != null ? c.getLocalName() : c.getNodeName();
if (name.equals(n) || (name.endsWith("[x]") && n.startsWith(name.substring(0, name.length()-3))))
children.add(c);
c = getNextSibling(c);
}
}
public static void getNamedChildrenWithTails(Element focus, String name, List<Element> children, Set<String> typeTails) {
Element c = getFirstChild(focus);
while (c != null) {
String n = c.getLocalName() != null ? c.getLocalName() : c.getNodeName();
if (n.equals(name) || (!n.equals("responseCode") && (n.startsWith(name) && typeTails.contains(n.substring(name.length())))))
children.add(c);
c = getNextSibling(c);
}
}
public static boolean hasNamedChild(Element e, String name) {
Element c = getFirstChild(e);
while (c != null && !name.equals(c.getLocalName()) && !name.equals(c.getNodeName()))
c = getNextSibling(c);
return c != null;
}
public static Document parseToDom(String content) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new ByteArrayInputStream(content.getBytes()));
}
public static Document parseFileToDom(String filename) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(false);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new FileInputStream(filename));
}
public static Element getLastChild(Element e) {
if (e == null)
return null;
Node n = e.getLastChild();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getPreviousSibling();
return (Element) n;
}
public static Element getPrevSibling(Element e) {
Node n = e.getPreviousSibling();
while (n != null && n.getNodeType() != Node.ELEMENT_NODE)
n = n.getPreviousSibling();
return (Element) n;
}
public static String getNamedChildAttribute(Element element, String name, String aname) {
Element e = getNamedChild(element, name);
return e == null ? null : e.getAttribute(aname);
}
public static void writeDomToFile(Document doc, String filename) throws TransformerException {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult streamResult = new StreamResult(new File(filename));
transformer.transform(source, streamResult);
}
public static String getXsiType(org.w3c.dom.Element element) {
Attr a = element.getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "type");
return (a == null ? null : a.getTextContent());
}
public static String getDirectText(org.w3c.dom.Element node) {
Node n = node.getFirstChild();
StringBuilder b = new StringBuilder();
while (n != null) {
if (n.getNodeType() == Node.TEXT_NODE)
b.append(n.getTextContent());
n = n.getNextSibling();
}
return b.toString().trim();
}
}

View File

@ -1,31 +1,31 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xml;
/*
@ -48,136 +48,136 @@ package org.hl7.fhir.utilities.xml;
* #L%
*/
import java.io.IOException;
public class XMLWriterState {
private String name;
private String namespace;
private boolean children;
private boolean inComment;
private boolean pretty;
private XMLNamespace[] namespaceDefns = null;
public void addNamespaceDefn(String namespace, String abbrev) throws IOException {
XMLNamespace ns;
ns = getDefnByAbbreviation(abbrev);
if (ns != null)
throw new IOException("duplicate namespace declaration on \""+abbrev+"\"");
ns = new XMLNamespace(namespace, abbrev);
if (namespaceDefns == null)
namespaceDefns = new XMLNamespace[] {ns};
else {
XMLNamespace[] newns = new XMLNamespace[namespaceDefns.length + 1];
for (int i = 0; i < namespaceDefns.length; i++) {
newns[i] = namespaceDefns[i];
}
namespaceDefns = newns;
namespaceDefns[namespaceDefns.length-1] = ns;
}
}
public XMLNamespace getDefnByNamespace(String namespace) {
if (namespaceDefns == null)
return null;
for (int i = 0; i < namespaceDefns.length; i++) {
XMLNamespace element = namespaceDefns[i];
if (element.getNamespace().equals(namespace))
return element;
}
return null;
}
public XMLNamespace getDefnByAbbreviation(String abbreviation) {
if (namespaceDefns == null)
return null;
for (int i = 0; i < namespaceDefns.length; i++) {
XMLNamespace element = namespaceDefns[i];
if (element.getAbbreviation() != null && element.getAbbreviation().equals(abbreviation))
return element;
}
return null;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* @return the children
*/
public boolean hasChildren() {
return children;
}
public void seeChild() {
this.children = true;
}
public XMLNamespace getDefaultNamespace() {
if (namespaceDefns == null)
return null;
for (int i = 0; i < namespaceDefns.length; i++) {
XMLNamespace element = namespaceDefns[i];
if (element.getAbbreviation() == null)
return element;
}
return null;
}
/**
* @return the inComment
*/
public boolean isInComment() {
return inComment;
}
/**
* @param inComment the inComment to set
*/
public void setInComment(boolean inComment) {
this.inComment = inComment;
}
/**
* @return the pretty
*/
public boolean isPretty() {
return pretty;
}
/**
* @param pretty the pretty to set
*/
public void setPretty(boolean pretty) {
this.pretty = pretty;
}
}
import java.io.IOException;
public class XMLWriterState {
private String name;
private String namespace;
private boolean children;
private boolean inComment;
private boolean pretty;
private XMLNamespace[] namespaceDefns = null;
public void addNamespaceDefn(String namespace, String abbrev) throws IOException {
XMLNamespace ns;
ns = getDefnByAbbreviation(abbrev);
if (ns != null)
throw new IOException("duplicate namespace declaration on \""+abbrev+"\"");
ns = new XMLNamespace(namespace, abbrev);
if (namespaceDefns == null)
namespaceDefns = new XMLNamespace[] {ns};
else {
XMLNamespace[] newns = new XMLNamespace[namespaceDefns.length + 1];
for (int i = 0; i < namespaceDefns.length; i++) {
newns[i] = namespaceDefns[i];
}
namespaceDefns = newns;
namespaceDefns[namespaceDefns.length-1] = ns;
}
}
public XMLNamespace getDefnByNamespace(String namespace) {
if (namespaceDefns == null)
return null;
for (int i = 0; i < namespaceDefns.length; i++) {
XMLNamespace element = namespaceDefns[i];
if (element.getNamespace().equals(namespace))
return element;
}
return null;
}
public XMLNamespace getDefnByAbbreviation(String abbreviation) {
if (namespaceDefns == null)
return null;
for (int i = 0; i < namespaceDefns.length; i++) {
XMLNamespace element = namespaceDefns[i];
if (element.getAbbreviation() != null && element.getAbbreviation().equals(abbreviation))
return element;
}
return null;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the namespace
*/
public String getNamespace() {
return namespace;
}
/**
* @param namespace the namespace to set
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* @return the children
*/
public boolean hasChildren() {
return children;
}
public void seeChild() {
this.children = true;
}
public XMLNamespace getDefaultNamespace() {
if (namespaceDefns == null)
return null;
for (int i = 0; i < namespaceDefns.length; i++) {
XMLNamespace element = namespaceDefns[i];
if (element.getAbbreviation() == null)
return element;
}
return null;
}
/**
* @return the inComment
*/
public boolean isInComment() {
return inComment;
}
/**
* @param inComment the inComment to set
*/
public void setInComment(boolean inComment) {
this.inComment = inComment;
}
/**
* @return the pretty
*/
public boolean isPretty() {
return pretty;
}
/**
* @param pretty the pretty to set
*/
public void setPretty(boolean pretty) {
this.pretty = pretty;
}
}

View File

@ -1,32 +1,32 @@
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
Copyright (c) 2011+, HL7, Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package org.hl7.fhir.utilities.xml;
/*
@ -49,57 +49,57 @@ package org.hl7.fhir.utilities.xml;
* #L%
*/
import java.io.IOException;
import java.util.Vector;
public class XMLWriterStateStack {
private Vector<XMLWriterState> items = new Vector<XMLWriterState>();
public int size(){
return items.size();
}
public boolean empty(){
return items.size() == 0;
}
public XMLWriterState current() throws IOException {
if (empty())
throw new IOException("stack is empty trying to get current");
return items.get(items.size() - 1);
}
public void push(XMLWriterState element) {
items.add(element);
}
public void clear () {
if (items != null)
items.clear();
}
public void pop() throws IOException {
if (empty())
throw new IOException("stack is empty trying to pop");
if (current().isInComment())
throw new IOException("Must close a comment sequence in the element in which it was started");
items.remove(items.size() - 1);
}
public XMLWriterState item(int index) {
return items.get(index);
}
public boolean inComment() {
for (int i = 0; i < items.size(); i++) {
if (items.get(i).isInComment())
return true;
}
return false;
}
}
import java.io.IOException;
import java.util.Vector;
public class XMLWriterStateStack {
private Vector<XMLWriterState> items = new Vector<XMLWriterState>();
public int size(){
return items.size();
}
public boolean empty(){
return items.size() == 0;
}
public XMLWriterState current() throws IOException {
if (empty())
throw new IOException("stack is empty trying to get current");
return items.get(items.size() - 1);
}
public void push(XMLWriterState element) {
items.add(element);
}
public void clear () {
if (items != null)
items.clear();
}
public void pop() throws IOException {
if (empty())
throw new IOException("stack is empty trying to pop");
if (current().isInComment())
throw new IOException("Must close a comment sequence in the element in which it was started");
items.remove(items.size() - 1);
}
public XMLWriterState item(int index) {
return items.get(index);
}
public boolean inComment() {
for (int i = 0; i < items.size(); i++) {
if (items.get(i).isInComment())
return true;
}
return false;
}
}

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -21,57 +21,57 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli-jpaserver</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<type>war</type>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli-jpaserver</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<type>jar</type>
<classifier>classes</classifier>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<classifier>classes</classifier>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -21,7 +21,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>provided</scope>
</dependency>
@ -29,33 +29,33 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- This dependency includes the JPA server itself, which is packaged separately from the rest of HAPI FHIR -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -18,7 +18,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
@ -38,12 +38,12 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -18,49 +18,49 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli-app</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<!-- Don't include in standard distribution -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-android</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<!-- Don't include in standard distribution -->
<scope>provided</scope>
</dependency>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -19,47 +19,47 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-client-okhttp</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -18,7 +18,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
@ -38,12 +38,12 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -31,7 +31,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jaxrsserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -23,7 +23,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
@ -34,32 +34,32 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
@ -424,7 +424,7 @@
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<executions>
<execution>
<id>build_dstu1</id>
@ -476,22 +476,22 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>

View File

@ -10,7 +10,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -35,40 +35,40 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- At least one "structures" JAR must also be included -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- This dependency includes the JPA server itself, which is packaged separately from the rest of HAPI FHIR -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -18,34 +18,34 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -19,37 +19,37 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -17,7 +17,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!--
@ -167,7 +167,7 @@
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<executions>
<execution>
<goals>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -18,13 +18,13 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2.1</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>test</scope>
</dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -17,13 +17,13 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>test</scope>
</dependency>
@ -179,7 +179,7 @@
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<executions>
<execution>
<id>generate</id>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -18,12 +18,12 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>test</scope>
</dependency>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -18,12 +18,12 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>test</scope>
</dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -27,28 +27,28 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-jpaserver-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!--<dependency> <groupId>ca.uhn.hapi.fhir</groupId> <artifactId>hapi-fhir-structures-dev</artifactId> <version>0.9</version> </dependency> -->
<dependency>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>
@ -17,7 +17,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -19,7 +19,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!--
Because Tinder is a part of the HAPI FHIR build process (it generates
@ -41,7 +41,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -17,17 +17,17 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
@ -50,7 +50,7 @@
<plugin>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<executions>
<execution>
<id>custom-structs</id>
@ -186,17 +186,17 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
@ -242,17 +242,17 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-tinder-plugin</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!--
<dependency>

View File

@ -11,7 +11,7 @@
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<packaging>pom</packaging>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<name>HAPI-FHIR</name>
<url>https://hapifhir.io</url>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -17,12 +17,12 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -8,7 +8,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -33,27 +33,27 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- At least one "structures" JAR must also be included -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
</dependency>
<!-- This dependency is used for the "FHIR Tester" web app overlay -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-testpage-overlay</artifactId>
<version>2.2-SNAPSHOT</version>
<version>2.2</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>

View File

@ -54,7 +54,6 @@
<td>HAPI FHIR 2.2</td>
<td><a href="http://build.fhir.org/">DSTU3 1.4.0 Snapshot</a> (May 2016 / Baltimore)</td>
</tr>
<tr>
<tr>
<td rowspan="6">hapi-fhir-structures-dstu3</td>
<td>HAPI FHIR 1.4</td>