Filtering the Associated Objects That Are Returned by a GetMetadataObjects Request

Search criteria that are specified in the <XMLSELECT search="criteria"/> element of a GetMetadataObjects method call filters the initial set of metadata objects that are retrieved. You can filter the associated objects that are retrieved by GetMetadataObjects by setting the OMI_GET_METADATA (256) and OMI_TEMPLATE (4) flags and specifying a Search attribute in the association name subelement of a template that requests associated objects.
Beginning in SAS 9.3, the Search attribute supports full search syntax as described in <XMLSELECT search="criteria"/> Syntax.
The Search attribute is specified as follows:
<AssociationName search="Object"/>
<AssociationName search="Object[Criteria]"/>
  • Object can be an * or a SAS Metadata Model metadata type. The metadata type must be a valid associated object for the specified <ASSOCIATIONNAME>.
    When Object is an *, the GetMetadataObjects method selects for retrieval all metadata types that are valid for <ASSOCIATIONNAME>, similar to specifying <ASSOCIATIONNAME/> without search criteria.
    When Object is a metadata type, the GetMetadataObjects method gets only associated objects of the specified metadata type.
  • [Criteria] is an attribute criteria specification or an association path specification that conforms to the syntax documented in <XMLSELECT search="criteria"/> Syntax. When criteria are specified, GetMetadataObjects gets only associated objects specified by Object that also meet the specified criteria.
The following is an example of a GetMetadataObjects request that specifies search criteria on an association name. The request specifies to get Document objects and ExternalTable objects that are associated with the Document objects through the Objects association and have the words Human Resources in their Desc attribute.
<GetMetadataObjects>
   <Reposid>A0000001.A5DQTZY5</Reposid>
   <Type>Document</Type>
   <Objects/>
   <NS>SAS</NS>
   <!-- OMI_GET_METADATA(256) + OMI_TEMPLATE (4) + OMI_ALL_SIMPLE (8) -->
   <Flags>268</Flags>  
   <Options>
      <Templates>
         <Document>
           <Objects search="ExternalTable[@Desc ? 'Human
Resources']"/>
         </Document>
      </Templates>
   </Options>
</GetMetadataObjects>
In the request, note the following:
  • The <REPOSID> element identifies the repository from which to get the objects.
  • The <TYPE> element specifies to get objects of metadata type Document.
  • The <FLAGS> element specifies the sum of the OMI_GET_METADATA, OMI_TEMPLATE, and OMI_ALL_SIMPLE flags (256 + 4 + 8 = 268). The OMI_GET_METADATA and OMI_TEMPLATE flags are required to process the request. OMI_ALL_SIMPLE is optional and is used here to show the filtering that occurs. When the required flags are used alone, the GetMetadataObjects method gets only the Id attribute of selected associated objects.
  • The <OPTIONS> element includes a <TEMPLATES> element that contains a template. The template specifies to get ExternalTable objects that are associated with the Document objects through the Objects association and have the words Human Resources in their Desc attribute.
Here is an example of the output from the request:
<!-- Using the GETMETADATAOBJECTS method. -->

<Objects>
   <Document Id="A5DQTZY5.B9000001" Name="MyDocument" ChangeState="" 
Desc="Document object created to do search string tests" LockedBy="" MetadataCreated=
"07Aug2008:14:04:35" MetadataUpdated="07Aug2008: 18:40:11" PublicType="Document" 
TextRole="" TextType="" URI="text file" URIType="" UsageVersion="1000000">
   <Objects SEARCH="ExternalTable[@Desc ? 'Human Resources']">
          <ExternalTable  Id="A5DQTZY5.BA000002" ChangeState="" Desc="Human Resources 
information from Oracle database" LockedBy="" MetadataCreated="07Aug2008:14:04:35" 
MetadataUpdated="07Aug2008: 18:40:36" Name="Oracle HR" NumRows="-1" PublicType=
"ExternalFile"  TableName="" UsageVersion="1000000"/>
         <ExternalTable  Id="A5DQTZY5.BA000004" ChangeState="" Desc="Human Resources
information from Sybase database" LockedBy="" MetadataCreated="07Aug2008:14:04:35" 
MetadataUpdated="07Aug2008: 18:40:36" Name="Sybase HR" NumRows="-1" PublicType=
"ExternalFile"  TableName="" UsageVersion="1000000"/>
   </Objects>
</Document>
</Objects>
Two ExternalTable objects were found that met the selection criteria.