DCMTK Version 3.6.9
OFFIS DICOM Toolkit
Loading...
Searching...
No Matches
DcmXMLParseHelper Class Reference

Helper class that provides methods for parsing an XML document in the format produced by dcm2xml into a DICOM dataset. More...

Public Member Functions

 DcmXMLParseHelper ()
 constructor;
 
virtual ~DcmXMLParseHelper ()
 destructor;
 
OFCondition readXmlFile (const char *ifname, DcmFileFormat &fileformat, E_TransferSyntax &xfer, const OFBool metaInfo, const OFBool checkNamespace, const OFBool validateDocument, const OFBool stopOnError)
 read an XML file containing a DICOM dataset in the format produced by dcm2xml, and convert it into a DICOM file
 

Static Public Member Functions

static void initLibrary ()
 initialize XML parser library.
 
static void cleanupLibrary ()
 cleanup internal memory used by the XML parser library.
 

Private Member Functions

OFBool convertUtf8ToCharset (const xmlChar *fromString, OFString &toString)
 convert from UTF-8 to the current DICOM character set
 
OFCondition checkNode (xmlNodePtr current, const char *name)
 check the type of the current XML node, report an error if there is a mismatch
 
OFCondition createNewElement (xmlNodePtr current, DcmElement *&newElem)
 create a new, empty DICOM element corresponding to the given XML node pointer
 
OFCondition putElementContent (xmlNodePtr current, DcmElement *element)
 parse an attribute value and store it in the given DICOM element
 
OFCondition parseElement (DcmItem *dataset, xmlNodePtr current)
 parse a DICOM element that is not a sequence
 
OFCondition parseSequence (DcmSequenceOfItems *sequence, xmlNodePtr current, E_TransferSyntax xfer, const OFBool stopOnError)
 parse a DICOM sequence
 
OFCondition parsePixelSequence (DcmPixelSequence *sequence, xmlNodePtr current, const OFBool stopOnError)
 parse a DICOM pixel sequence of a compressed image files
 
OFCondition parseMetaHeader (DcmMetaInfo *metainfo, xmlNodePtr current, const OFBool parse, const OFBool stopOnError)
 parse the metaheader part of an XML file containing a DICOM file.
 
OFCondition parseDataSet (DcmItem *dataset, xmlNodePtr current, E_TransferSyntax xfer, const OFBool stopOnError)
 parse the dataset part of an XML file containing a DICOM file or a DICOM dataset.
 
OFCondition validateXmlDocument (xmlDocPtr doc)
 validate the given XML document and print error output if the validation fails
 

Private Attributes

xmlCharEncodingHandlerPtr EncodingHandler
 stores pointer to character encoding handler
 

Detailed Description

Helper class that provides methods for parsing an XML document in the format produced by dcm2xml into a DICOM dataset.

Member Function Documentation

◆ checkNode()

OFCondition DcmXMLParseHelper::checkNode ( xmlNodePtr current,
const char * name )
private

check the type of the current XML node, report an error if there is a mismatch

Parameters
currentpointer to current XML node
nameexpected name of the current XML node
Returns
EC_Normal upon success, an error code otherwise

◆ cleanupLibrary()

static void DcmXMLParseHelper::cleanupLibrary ( )
static

cleanup internal memory used by the XML parser library.

This function should be called once before the application terminates. It is not re-entrant.

◆ convertUtf8ToCharset()

OFBool DcmXMLParseHelper::convertUtf8ToCharset ( const xmlChar * fromString,
OFString & toString )
private

convert from UTF-8 to the current DICOM character set

Parameters
fromStringinput string
toStringoutput string
Returns
EC_Normal upon success, an error code otherwise

◆ createNewElement()

OFCondition DcmXMLParseHelper::createNewElement ( xmlNodePtr current,
DcmElement *& newElem )
private

create a new, empty DICOM element corresponding to the given XML node pointer

Parameters
currentpointer to current XML node
newElem
Returns
EC_Normal upon success, an error code otherwise

◆ initLibrary()

static void DcmXMLParseHelper::initLibrary ( )
static

initialize XML parser library.

This function should be called once before any libxml2 code is used. This function is not re-entrant.

◆ parseDataSet()

OFCondition DcmXMLParseHelper::parseDataSet ( DcmItem * dataset,
xmlNodePtr current,
E_TransferSyntax xfer,
const OFBool stopOnError )
private

parse the dataset part of an XML file containing a DICOM file or a DICOM dataset.

Parameters
datasetdataset stored in this parameter
currentpointer to current XML node
xfertransfer syntax in which the XML file is read
stopOnErrorif true, stop parsing and return an error code upon encountering a parse error, otherwise ignore parse errors and continue
Returns
EC_Normal upon success, an error code otherwise

◆ parseElement()

OFCondition DcmXMLParseHelper::parseElement ( DcmItem * dataset,
xmlNodePtr current )
private

parse a DICOM element that is not a sequence

Parameters
dataset
currentpointer to current XML node
Returns
EC_Normal upon success, an error code otherwise

◆ parseMetaHeader()

OFCondition DcmXMLParseHelper::parseMetaHeader ( DcmMetaInfo * metainfo,
xmlNodePtr current,
const OFBool parse,
const OFBool stopOnError )
private

parse the metaheader part of an XML file containing a DICOM file.

Parameters
metainfometaheader stored in this parameter
currentpointer to current XML node
parseif true, parse the metaheader, otherwise just skip it
stopOnErrorif true, stop parsing and return an error code upon encountering a parse error, otherwise ignore parse errors and continue
Returns
EC_Normal upon success, an error code otherwise

◆ parsePixelSequence()

OFCondition DcmXMLParseHelper::parsePixelSequence ( DcmPixelSequence * sequence,
xmlNodePtr current,
const OFBool stopOnError )
private

parse a DICOM pixel sequence of a compressed image files

Parameters
sequence
currentpointer to current XML node
stopOnErrorif true, stop parsing and return an error code upon encountering a parse error, otherwise ignore parse errors and continue
Returns
EC_Normal upon success, an error code otherwise

◆ parseSequence()

OFCondition DcmXMLParseHelper::parseSequence ( DcmSequenceOfItems * sequence,
xmlNodePtr current,
E_TransferSyntax xfer,
const OFBool stopOnError )
private

parse a DICOM sequence

Parameters
sequence
currentpointer to current XML node
xfertransfer syntax in which the XML file is read
stopOnErrorif true, stop parsing and return an error code upon encountering a parse error, otherwise ignore parse errors and continue
Returns
EC_Normal upon success, an error code otherwise

◆ putElementContent()

OFCondition DcmXMLParseHelper::putElementContent ( xmlNodePtr current,
DcmElement * element )
private

parse an attribute value and store it in the given DICOM element

Parameters
currentpointer to current XML node
elementattribute value stored in this element
Returns
EC_Normal upon success, an error code otherwise

◆ readXmlFile()

OFCondition DcmXMLParseHelper::readXmlFile ( const char * ifname,
DcmFileFormat & fileformat,
E_TransferSyntax & xfer,
const OFBool metaInfo,
const OFBool checkNamespace,
const OFBool validateDocument,
const OFBool stopOnError )

read an XML file containing a DICOM dataset in the format produced by dcm2xml, and convert it into a DICOM file

Parameters
ifnamename of the XML file to be read
fileformatDcmFileFormat instance to be populated with the parsed XML content
xferoutput parameter indicating the transfer syntax to which the XML file was parsed
metaInfoif true, metaheader attributes are read from the XML file, otherwise they are ignored
checkNamespaceif true, check XML namespace in document root
validateDocumentif true, validate the XML document after parsing
stopOnErrorif true, stop parsing and return an error code upon encountering a parse error, otherwise ignore parse errors and continue
Returns
EC_Normal upon success, an error code otherwise

◆ validateXmlDocument()

OFCondition DcmXMLParseHelper::validateXmlDocument ( xmlDocPtr doc)
private

validate the given XML document and print error output if the validation fails

Parameters
docpointer to XML document
Returns
EC_Normal upon successful validation, an error code otherwise

The documentation for this class was generated from the following file:


Generated on Wed Apr 23 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2