2

I have tried the following code to get xml.

void getListXml(ICoreService endpoint, String myUri) throws Exception {
        TaxonomiesFilterData filter = new TaxonomiesFilterData();
        Element listXml = (Element) endpoint.getListXml(myUri, filter).getAny();

        NodeList items = listXml.getElementsByTagName("tcm:Item");
        System.out.println("xml element is : " + listXml);
        for (int i = 0; i < items.getLength(); i++) {
            Element itemXml = (Element) items.item(i);
            System.out.println(itemXml.getAttribute("Title"));
        }
    }

but i am getting error with message

com.sdltridion.contentmanager.coreservice.ICoreServiceGetListXmlCoreServiceFaultFaultFaultMessage: Unexpected item type: Category.

it would be helpful if get some input on this.

EDIT : I have Changed the implementation to TaxonomiesOwlFilter

        TaxonomiesOwlFilterData taxonomyFilter = new TaxonomiesOwlFilterData();
        ArrayOfLinkToCategoryData arrayOfLinkToCategoryData = new ArrayOfLinkToCategoryData(){
            @Override
            public List<LinkToCategoryData> getLinkToCategoryData() {
                List<LinkToCategoryData> linkToCategoryDatas = new ArrayList<>();
                LinkToCategoryData linkToCategoryData = new LinkToCategoryData();
                linkToCategoryData.setIdRef(new JAXBElement<String>(new QName("http://www.sdltridion.com/ContentManager/R6","IdRef"), String.class, categoryId));
                return linkToCategoryDatas;
            }
        };

        taxonomyFilter.setRootCategories(new JAXBElement<ArrayOfLinkToCategoryData>(new QName("http://www.sdltridion.com/ContentManager/R6","RootCategories"),ArrayOfLinkToCategoryData.class,arrayOfLinkToCategoryData));
        GetListXmlResult getListXmlResult  = endpoint.getListXml(publicationId, taxonomyFilter);
        System.out.println(getListXmlResult.getAny());

then i am getting output as :

[rdf:RDF: null]

5
  • What's the value of myUri? I'm assuming endpoint.GetListXml is the line where the exception occurrs. Oct 18, 2016 at 12:00
  • Hi Nickoli, it is Category tcmUri like tcm:x-xxx-xxx, yes it is error while calling getListXml() Oct 18, 2016 at 12:31
  • What's the actual value though? Oct 18, 2016 at 14:23
  • I have edited my question. Oct 19, 2016 at 12:29
  • I guess getListXmlResult.getAny() represents an XML element (the root element of the OWL). Not sure what System.out.println does with an XML element as input, but it seems to output the tag name, which seems correct. Oct 19, 2016 at 13:39

1 Answer 1

3

If you use GetListXml with TaxonomiesFilterData, you should pass in a Publication ID as id parameter: it returns a list of all Taxonomies within the given Publication.

In case you intended to get the Taxonomy XML/OWL for a single Taxonomy: use TaxonomiesOwlFilterData for that purpose. You will still have to specify a Publication ID as id parameter, but you can also specify one or more Category IDs in TaxonomiesOwlFilterData.RootCategories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.