DCMTK: DcmXMLParseHelper Class Reference

DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
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

  current | pointer to current XML node
  name | expected name of the current XML node

Returns
  EC_Normal upon success, an error code otherwise

## ◆ cleanupLibrary()

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

  fromString | input string
  toString | output 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

  current | pointer to current XML node
  newElem |

Returns
  EC_Normal upon success, an error code otherwise

## ◆ initLibrary()

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

  dataset | dataset stored in this parameter
  current | pointer to current XML node
  xfer | transfer syntax in which the XML file is read
  stopOnError | if 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 |
  current | pointer 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

  metainfo | metaheader stored in this parameter
  current | pointer to current XML node
  parse | if true, parse the metaheader, otherwise just skip it
  stopOnError | if 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 |
  current | pointer to current XML node
  stopOnError | if 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 |
  current | pointer to current XML node
  xfer | transfer syntax in which the XML file is read
  stopOnError | if 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

  current | pointer to current XML node
  element | attribute 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

  ifname | name of the XML file to be read
  fileformat | DcmFileFormat instance to be populated with the parsed XML content
  xfer | output parameter indicating the transfer syntax to which the XML file was parsed
  metaInfo | if true, metaheader attributes are read from the XML file, otherwise they are ignored
  checkNamespace | if true, check XML namespace in document root
  validateDocument | if true, validate the XML document after parsing
  stopOnError | if 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

  doc | pointer to XML document

Returns
  EC_Normal upon successful validation, an error code otherwise

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

- dcmdata/include/dcmtk/dcmdata/dcmxml/xml2dcm.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.16.1