XML 색인화 아티팩트 검색

XML 검색 색인 규칙에 의해 색인화된 컨텐츠를 검색하려면 elementName[attributeName='attributeValue'] 형식으로 검색 텍스트를 정의하십시오. RAMAssetQueryBuilder의 속성 조회 필드로서 이 검색 텍스트를 추가하십시오. 결과로 나오는 ArtifactSearchResults를 통해 특정 XML과 일치하는 결과 항목을 검색할 수 있습니다. 다음은 XML 데이터 내 검색에 대한 예제 형식입니다.
  • 요소 없이 검색: attributeName='attributeValue'
  • 단일 요소에 정의된 여러 속성 검색: elementName[attributeName1='attributeValue1' attributeName2='attributeValue2]
  • 전체 경로 검색: elementPath1/elementPath2[attributeName='attributeValue']
  • 요소 내 텍스트 검색: elementName[text()='textValue']
  • XML 문서 검색 시 와일드 카드 문자 사용 가능: 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]);
		 		 		 		 }
		 		 		 }
				 }

피드백