Search XML indexed artifacts

To search the content indexed by XML search index rules define your search text in the form elementName[attributeName='attributeValue']. Add this search text as an attribute query field on your RAMAssetQueryBuilder. The results down to the specific XML matches can be retrieved by through the resulting ArtifactSearchResults. Example formats for searching within XML data.
  • Search without an element: attributeName='attributeValue'
  • Search for multiple attributes defined in a single element: elementName[attributeName1='attributeValue1' attributeName2='attributeValue2]
  • Search for an entire path: elementPath1/elementPath2[attributeName='attributeValue']
  • Search for text within an element: elementName[text()='textValue']
  • The wilcard character may also be used when searching for XML documents: elementName[attributeName='attribute*']
				 //Perform search into XML indexed content
		 		 RAMAssetQueryBuilder query = new RAMAssetQueryBuilder(session);
				 
		 		 //Make sure search within artifacts is on
		 		 query.setSearchModes(SearchQuery.SEARCH_WITHIN_ARTIFACTS_FLAG);
		 		 
		 		 //XML index search text in the form elementName[attributeName='attributeValue']
		 		 String searchText = "wsdl:definitions[targetNamespace='*example*']";
		 		 query.addQueryField(query.QUERY_FIELD_ATTRIBUTE, searchText);
		 		 
		 		 //Perform search
		 		 SearchResult result = session.getAssets(query);
		 		 
		 		 //Get the list of asset matches
		 		 AssetSearchResult[] results = result.getAssetSearchResults();
		 		 
		 		 for(int i = 0; i < results.length; i++){
		 		 		 //For an asset match get the list of artifact matches
		 		 		 ArtifactSearchResult[] artifactMatches = results[i].getMatchingArtifacts();
		 		 		 
		 		 		 for(int j = 0; j < artifactMatches.length; j++){
		 		 		 		 //For an artifact match get the XML index matches
		 		 		 		 String[] xmlIndexMatches = artifactMatches[j].getMatches();
		 		 		 		 
		 		 		 		 for(int k = 0; k < xmlIndexMatches.length; k++){
		 		 		 		 		 System.out.println("Match = " + xmlIndexMatches[k]);
		 		 		 		 }
		 		 		 }
				 }

Feedback