[ismrmrd] 57/281: Added functions to bind xml

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Jan 14 20:00:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag ismrmrd0.5
in repository ismrmrd.

commit 6202157923a621cb53509ab86f88df0ac5664f29
Author: Souheil Inati <souheil.inati at nih.gov>
Date:   Thu Sep 27 15:38:35 2012 -0400

    Added functions to bind xml
---
 matlab/+ismrmrd/headerToString.m | 15 +++++++++++++++
 matlab/+ismrmrd/stringToHeader.m | 12 ++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/matlab/+ismrmrd/headerToString.m b/matlab/+ismrmrd/headerToString.m
new file mode 100644
index 0000000..93453bd
--- /dev/null
+++ b/matlab/+ismrmrd/headerToString.m
@@ -0,0 +1,15 @@
+function xmlstring = headerToString(hdr)
+
+    jpath = fileparts(mfilename('fullpath'));
+    javaaddpath({fullfile(jpath,'ismrmrdxml.jar')});
+    import javax.xml.bind.*
+
+    jc = JAXBContext.newInstance('ismrmrdxml', hdr.getClass().getClassLoader());
+    m  = jc.createMarshaller();
+    m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, 'http://www.ismrm.org/ISMRMD ismrmrd.xsd');
+
+    strbuff = java.io.StringWriter();
+    m.marshal(hdr, strbuff);
+    xmlstring = strbuff.toString();
+
+end
diff --git a/matlab/+ismrmrd/stringToHeader.m b/matlab/+ismrmrd/stringToHeader.m
new file mode 100644
index 0000000..6d4d791
--- /dev/null
+++ b/matlab/+ismrmrd/stringToHeader.m
@@ -0,0 +1,12 @@
+function hdr = stringToHeader(xmlstring)
+
+    jpath = fileparts(mfilename('fullpath'));
+    javaaddpath({fullfile(jpath,'ismrmrdxml.jar')});
+    import javax.xml.bind.*
+    of = ismrmrdxml.ObjectFactory();
+    jc = JAXBContext.newInstance('ismrmrdxml', of.getClass().getClassLoader());
+    u  = jc.createUnmarshaller();
+    jstr = java.lang.String(xmlstring);
+    hdr = u.unmarshal(java.io.ByteArrayInputStream(jstr.getBytes()));
+    
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ismrmrd.git



More information about the debian-science-commits mailing list