Functions
XML Element Scanning Functions

Functions

bool mdlElement_isXMLFragment (MSElementCP pElm)
 Determines whether or not the input element is an XML Fragment Element. More...
 
bool mdlElement_isXMLFragmentByAppIDAndType (MSElementCP pElm, UInt16 *pAppID, UInt16 *pAppType)
 Determines whether or not the input element is an XML Fragment Element based on optional appId and appType values. More...
 
bool mdlElement_hasXMLFragmentAttachment (MSElementP pElm, UInt16 *pAppID, UInt16 *pAppType)
 Determines whether or not the input element has an XML Fragment attachment. More...
 
StatusInt mdlXML_addXMLFragmentAttachmentScanTest (DgnPlatform::ScanCriteria *pScanCriteria, UInt16 *pAppID, UInt16 *pAppType)
 Sets the scan criteria to find elements with XMLFragment attachments. More...
 
StatusInt mdlXML_addXMLFragmentElementScanTest (DgnPlatform::ScanCriteria *pScanCriteria, UInt16 *pAppID, UInt16 *pAppType)
 Sets the scan criteria to find XMLFragment elements. More...
 
StatusInt mdlXMLElement_getAppInfo (UInt16 *pAppID, UInt16 *pAppType, MSElementCP pElm)
 Retrieves the application identifier and/or type from the given XML Fragment Element. More...
 
StatusInt mdlXMLElement_setNonModelCategory (MSElementDescrP pDescr, bool isNonModelElement)
 Sets the non-model flag for a XMLFragment element. More...
 

Detailed Description

Function Documentation

bool mdlElement_hasXMLFragmentAttachment ( MSElementP  pElm,
UInt16 pAppID,
UInt16 pAppType 
)

Determines whether or not the input element has an XML Fragment attachment.

Parameters
[in]pElmElement to test.
[in]pAppIDPointer to variable containing application id to search for. (or NULL if criteria not applied)
[in]pAppTypePointer to variable containing application type to search for. (or NULL if criteria not applied)
Returns
true if element is an XML Element, false otherwise.
Remarks
pAppId parameter must be non-NULL if pAppType is non-NULL.
Required Library: mdlbltin.lib
bool mdlElement_isXMLFragment ( MSElementCP  pElm)

Determines whether or not the input element is an XML Fragment Element.

XMLInDgn API Description

XMLInDgn is the set of functionality that allows XML to be stored in DGN files. Data can be stored as XML Elements, or XML Attachments to elements.

XML DGN Element and XML Schema DGN Element

XML DGN Elements will typically hold well-formed fragments of XML documents. It will also contain additional ids to indicate which application it belongs to and the subtype within that application. It may contain a reference to the applicable schema.

XML DGN Element Attachment

An element attachment known to contain XML data. It will also contain additional ids to indicate which application it belongs to and the subtype within that application. It may contain a reference to the applicable schema. XML DGN Element attachments will typically hold well-formed fragments of XML documents.

Include files

To use the API you include the following:

Linking

To use the API you link the following:

  • mdlxml.dlo - Link this file with MDL Objects.
  • mdlxml.lib - Link this file with C Objects.

Function Sets

  • XML Fragment/FragmentList Functions
  • XML-related Element and Scanning Functions

XML-related Element and Scanning Functions

The following functions allow you to determine if an element is an XML Fragment element or has XML Fragment linkage attachments.

The following functions allow you to specify scan criteria to find XMLFragment elements or elements with XMLFragment linkage attachments.

Parameters
[in]pElmElement to test.
Returns
true if element is an XML Element, false otherwise.
Remarks
Required Library: mdlbltin.lib
bool mdlElement_isXMLFragmentByAppIDAndType ( MSElementCP  pElm,
UInt16 pAppID,
UInt16 pAppType 
)

Determines whether or not the input element is an XML Fragment Element based on optional appId and appType values.

Parameters
[in]pElmElement to test.
[in]pAppIDPointer to variable containing application id to search for. (or NULL if criteria not applied).
[in]pAppTypePointer to variable containing application type to search for. (or NULL if criteria not applied).
Returns
true if element is an XML Element, false otherwise.
Remarks
pAppId parameter must be non-NULL if pAppType is non-NULL.
Required Library: mdlbltin.lib
StatusInt mdlXML_addXMLFragmentAttachmentScanTest ( DgnPlatform::ScanCriteria *  pScanCriteria,
UInt16 pAppID,
UInt16 pAppType 
)

Sets the scan criteria to find elements with XMLFragment attachments.

Parameters
[in,out]pScanCriteriaScan criteria.
[in]pAppIDPointer to variable containing application id to search for. (or NULL if criteria not applied)
[in]pAppTypePointer to variable containing application type to search for. (or NULL if criteria not applied)
Returns
normally SUCCESS; MDLERR_BADARG if pScanCriteria pointer is invalid. MDLERR_BADARG if pAppID=NULL and pAppType!=NULL
Remarks
Elements can be filtered by application ID and type. An application type may not be passed alone, it must always be passed with an application ID.
StatusInt mdlXML_addXMLFragmentElementScanTest ( DgnPlatform::ScanCriteria *  pScanCriteria,
UInt16 pAppID,
UInt16 pAppType 
)

Sets the scan criteria to find XMLFragment elements.

Parameters
[in,out]pScanCriteriaScan criteria.
[in]pAppIDPointer to variable containing application id to search for. (or NULL)
[in]pAppTypePointer to variable containing application type to search for. (or NULL)
Returns
normally SUCCESS; MDLERR_BADARG if pScanCriteria pointer is invalid. MDLERR_BADARG if pAppID=NULL and pAppType!=NULL
Remarks
Elements can be filtered by application ID and type. An application type may not be passed alone, it must always be passed with an application ID.
StatusInt mdlXMLElement_getAppInfo ( UInt16 pAppID,
UInt16 pAppType,
MSElementCP  pElm 
)

Retrieves the application identifier and/or type from the given XML Fragment Element.

Parameters
[out]pAppIDThe ID of the "app" to which this XMLFragment Element belongs (typically an application's LinkageID). Pass NULL if data not needed.
[out]pAppTypeThe App type of XML Fragment Element. Pass NULL if data not needed. The app type is an application assigned value which uniquely identifies the XML Fragment within the application.
[in]pElmXML Fragment Element.
Returns
normally SUCCESS; MDLERR_BADARG if XMLFragment Element pointer is invalid; MDLERR_BADARG if both pAppID and pAppType pointers are NULL. MDLERR_BADELEMENTTYPE if element is not an XML Fragment Element.
Remarks
The following is an example of getting the appType of a XMLFragment element:
int myCompanyXmlFragmentScanCallback
(
MSElementDescrP pElement,
void* pArgs,
DgnPlatform::ScanCriteria* pScanCriteria
)
{
UInt16 appType=0;
StatusInt status;
status = mdlXMLElement_getAppInfo (NULL, &appType, &pElement->el);
if (SUCCESS != status)
return status;
switch (appType)
{
case 1:
// Do something with my company's Xml Fragment type 1
break;
case 2:
// Do something with my company's Xml Fragment type 2
break;
}
return SUCCESS;
}
int processXmlElements
(
)
{
UInt16 appID=1234; // my company id
DgnPlatform::ScanCriteria* pScanCriteria;
pScanCriteria = @ref mdlScanCriteria_create();
if (NULL == pScanCriteria)
return ERROR;
@ref mdlScanCriteria_setReturnType (pScanCriteria, MSSCANCRIT_ITERATE_ELMDSCR, false, true);
@ref mdlScanCriteria_setElmDscrCallback (pScanCriteria, myCompanyXmlFragmentScanCallback, NULL);
// Scan for my company's XML Fragment elements
@ref mdlXML_addXMLFragmentElementScanTest (pScanCriteria, &appID, NULL);
@ref mdlScanCriteria_scan (pScanCriteria, NULL, NULL, NULL);
@ref mdlScanCriteria_free (pScanCriteria);
}
StatusInt mdlXMLElement_setNonModelCategory ( MSElementDescrP  pDescr,
bool  isNonModelElement 
)

Sets the non-model flag for a XMLFragment element.

Remarks
By default, a XMLFragment element is added to a model in the control element category. By specifying isNonModelElement=true in this function, a XMLFragment element, when written, is stored in the dictionary model of a design file.
Parameters
[in,out]pDescrElement whose non-model flag is set.
[in]isNonModelElementtrue if element to be stored in dictionary model.
Returns
normally SUCCESS; MDLERR_BADARG if pDescr pointer is invalid; MDLERR_BADELEMENTTYPE if element is not an XML Fragment Element.
Remarks
The following is an example of creating a XMLFragment element and writing it to the dictionary model of the active design file:
{
UInt16 appID=12345;
UInt16 appType=1;
StatusInt status;
XMLFragmentListP fragmentList=NULL;
fragmentList = @ref mdlXMLFragmentList_construct (L"<node1>value1</node1>", NULL, appID, appType);
status = @ref mdlXMLFragmentList_createXMLElementDescriptor (&edP, &fragmentList, true);
@ref mdlElmdscr_add (edP);
@ref mdlElmdscr_freeAll (&edP);
}

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.