Filtering a GetMetadataObjects Request |
Search criteria that are specified in the <XMLSELECT> 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_GETMETADATA (256) and OMI_TEMPLATE (4) flags and specifying a search criteria string in the association name subelement of a template that requests associated objects.
The search criteria specified in an association name subelement supports a reduced form of the XMLSELECT syntax. The search criteria string supports object and attribute criteria in the following forms:
<AssociationName search="Object"/>
<AssociationName search="Object[AttributeCriteria]"/>
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.
[AttributeCriteria] is an attribute specification that conforms to the syntax documented in Attribute Criteria Component Syntax. When attribute criteria are specified, GetMetadataObjects gets only associated objects specified by Object, which also meet the specified attribute criteria.
This syntax is a change from SAS 9.1, which supported search criteria in the following form:
<AssociationName search="AttributeCriteria"/>
The SAS 9.2 syntax improves performance by enabling users to limit the number of metadata types on which the attribute criteria are evaluated. The older syntax is still supported in SAS 9.2, and is the same as specifying "*[AttributeCriteria]".
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.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.