Menu

Loading a Taxonomy?

Help
Anonymous
2012-08-08
2013-05-02
  • Anonymous

    Anonymous - 2012-08-08

    I am a bit new in the world of XBRL and XBRL Api.
    Currenly I am looking how I can load and explore a Taxonomy.
    How can I do this?
    And then use it to create a XBRL doc?
    - Ed

     
  • Nnang

    Nnang - 2012-08-17

    I am also interesting in loading and exploring an XBRL-Taxonomy. I couldn´t get it from the examples in the XBRL-Api.

    Thanks
    Virgo

     
  • Geoffrey Shuetrim

    The examples are what we have, and the many unit tests that are distributed along with the source code on sourceforge.  If you have specific code that is not working for you, put that forward, along with your error traces and we can give you more assistance.

    Regards

    Geoff Shuetrim 

     
  • Nnang

    Nnang - 2012-08-20

    Thanks for the response. I have run the Load and Run Examples from the package: org.xbrlapi.data.bdbxml.examples.
    By the Load-Example, I have realised that the Implementation of load is more "Loading the taxonomy" in the DB.

    In my case, I have already the complete Taxonomy an I just want to read it an show it on the Screen, so that the User can scroll the tree-representation of the taxonomy for more Details.

    In the Run example, I don´t also know if it can help me to read and show the Taxonomy on the Screen, though I succed to run it.

    Thanks
    Virgo

     
  • Geoffrey Shuetrim

    Glad you got the run example to work.  After you have loaded the taxonomy, you need to query the data store that holds it to find the information that you want to display.  The API gives you a lot of support in this - read the javadoc.  Mowt importantly, have a look at the aspects packages (in teh base module and the XDT module).  Another user has contributed an example of how to do this and I will be posting that to the website later this week.  You could also look at the instance rendering example that uses Freemarker templates to give presentation structure to the information that you are extracting from the instance and DTS that you have loaded into the data store.

    Cheers

    Geoff Shuetrim

     
  • Nnang

    Nnang - 2012-08-24

    Thanks for the given direction. I get the following  error by trying to follow it. I´ve created hte Class Explore in order to browse the Taxonomy and I just copy the code of the Run-Example. The emphasized Line is the one causing the Error.

    What can I do here ?

    java.lang.ClassCastException: org.xbrlapi.impl.LocatorImpl cannot be cast to org.xbrlapi.Concept
    at org.xbrlapi.data.bdbxml.examples.explore.Explore.browse(Explore.java:353)
    at org.xbrlapi.data.bdbxml.examples.explore.Explore.main(Explore.java:121)

    Map<String, Object> model = new HashMap<String, Object>();
    // Initialize the data model to be merged with the Freemarker template.
    SimpleDateFormat fmt = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");
    model.put("store", store);
    model.put("iso4217",org.xbrlapi.utilities.Constants.ISO4217);
    model.put("xbrli",org.xbrlapi.utilities.Constants.XBRL21Namespace);
    model.put("now", fmt.format(new Date()));

    // Iterate the presentation networks in the DTS
    List<Map<String, Object>> tables = new Vector<Map<String, Object>>();
    model.put("tables", tables);

    // Configure the aspect model (useful for sorting facts by their aspects)
    AspectModel aspectModel = new DimensionalAspectModelWithStoreCachingLabellers(store);
    aspectModel.initialise();
    Aspect periodAspect = aspectModel.getAspect(PeriodAspect.ID);
    aspectModel.addAspect("column",periodAspect);

    // Iterate the presentation networks
    // Add a table of information to the data model for each network.
    int counter = 0;
    // int target = 2;
    String arcrole = org.xbrlapi.utilities.Constants.PresentationArcrole;
    for (String linkRole : store.getLinkRoles(arcrole)) {

        try {
    counter++;

    //if (counter != target) continue;

    Map<String, Object> table = new HashMap<String, Object>();
    tables.add(table);
    String title = linkRole.toString();
    List<RoleType> roleDeclarations = store.getRoleTypes(linkRole);
    if (roleDeclarations.size() > 0) {
        title = roleDeclarations.get(0).getDefinition();
    }
    table.put("title", title);
    // logger.info("Setting up data model for : " + title);

    // Create the fact set for this network.
    FactSet factSet = new FactSetImpl(aspectModel);               

    Set<Concept> roots = store.<Concept>getNetworkRoots(linkRole,arcrole);
    // logger.info("There are " + roots.size() + " root concepts in network " + linkRole);

    maxLevel = 1;
    Concepts concepts = new Concepts();
    for (Concept root : roots) {
        concepts.addAll(
                parsePresentation(
                factSet,
                "",
                null,
                root,
                new Double(0.0),
                linkRole,
                arcrole,
                org.xbrlapi.utilities.Constants.StandardLabelRole)
        );
    }

    // Get the sorted set of period aspect values
    SortedSet<AspectValue> periods = new TreeSet<AspectValue>(periodAspect.getDomain());
    periods.addAll(factSet.getAspectValues(PeriodAspect.ID));
    periods.remove(new PeriodAspectValue());

    // Map from concept name (resolved QName) to the concept label.
    table.put("factSet", factSet);
    table.put("conceptAspect",aspectModel.getAspect(ConceptAspect.ID));
    table.put("periodAspect",aspectModel.getAspect(PeriodAspect.ID));
    // logger.info("# concepts in " + table.get("title") +  " = " + concepts.size());
    table.put("concepts", concepts.concepts);
    table.put("labels", concepts.labels);
    table.put("labelRoles", concepts.labelRoles);
    table.put("periods",periods);
    table.put("maxLevel", maxLevel);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
       

     
  • Geoffrey Shuetrim

    On line 353 of your code, you are attempting to use a locator fragment (a locator in an XLink linkbase) as a concept fragment (a special kind of XML Schema element declaration).  They are both extensions of an underlying class but locators do not extend concepts.

    I could not see which was your line 353 but that is the place to start.

    Regards

    Geoff S

     
  • Nnang

    Nnang - 2012-08-25

    Thanks for the response. You are right, but I don´t know how to solve it. I just copy the code of the run-example. The line causing the problem is :
    for (Concept root : roots) {…

    this is although this declaration Set<Concept> roots = store.<Concept>getNetworkRoots(linkRole,arcrole); was done.

    Thanks

    Virgo

     
  • Nnang

    Nnang - 2012-08-25

    Hi,

    Please, I really really need your help.

    Thanks
    Virgo

     
  • Nnang

    Nnang - 2012-08-27

    I adapted the code on this way to solve the problem:

        // Parses a presentation network given a parent concept in the network
        private static  Concepts parsePresentation(
                FactSet factSet,
                String indent,          
                Concept concept,
                Double order,
                String linkRole,
                String arcrole,
                String labelRole, String stufe
                ) throws Exception {

            // Define the concepts structure for the child concepts of this concept.
            Concepts myConcepts = new Concepts();       
     
            // Update the maximum indentation level that is used by the rendering
            maxLevel = Math.max(indent.length(), maxLevel);      
       
    List<LabelResource> labelResources = concept.getLabelsWithLanguageAndResourceRole("de", labelRole);
    String label;
    if (labelResources.size() > 0) {
    label = labelResources.get(0).getStringValue().trim();
    System.out.println(stufe + label);
    } else {
    label = concept.getName();
    }
    label = indent + label;       
            // Get the active presentation relationships from the given concept.
            SortedSet<Relationship> relationships = store.getRelationshipsFrom(concept.getIndex(),linkRole,arcrole);

            Concepts childConcepts = new Concepts();
            for (Relationship relationship: relationships) {
                  Arc arc = relationship.getArc();
                labelRole = org.xbrlapi.utilities.Constants.StandardLabelRole;
                if (arc.hasAttribute("preferredLabel")) {
                    String preferredLabelRole = arc.getAttribute("preferredLabel");
                    labelRole = preferredLabelRole;
                }
                childConcepts.addAll(
                    parsePresentation(
                        factSet,
                        indent + " ",
                        (Concept) relationship.getTarget(),
                        relationship.getArcOrder(),
                        linkRole,
                        arcrole,
                        labelRole, stufe+"+")
                        );
            }
    myConcepts.add(concept, label, labelResources.get(0).getResourceRole());
    myConcepts.addAll(childConcepts);        
            return myConcepts;
        }   

        private static void browse() {

            try {       
    Map<String, Object> model = new HashMap<String, Object>();

    // Iterate the presentation networks in the DTS
    List<Map<String, Object>> tables = new Vector<Map<String, Object>>();
    model.put("tables", tables);

    // Configure the aspect model (useful for sorting facts by their aspects)
    AspectModel aspectModel = new DimensionalAspectModelWithStoreCachingLabellers(store);
    aspectModel.initialise();
    Aspect periodAspect = aspectModel.getAspect(PeriodAspect.ID);
    aspectModel.addAspect("column",periodAspect);

    // Iterate the presentation networks
    // Add a table of information to the data model for each network.
    int counter = 0;

    String arcrole = org.xbrlapi.utilities.Constants.PresentationArcrole;
    int i = 0;
    for (String linkRole : store.getLinkRoles(arcrole)) {
        try {
    counter++;

    String title = linkRole.toString();
    List<RoleType> roleDeclarations = store.getRoleTypes(linkRole);
    if (roleDeclarations.size() > 0) {
        title = roleDeclarations.get(0).getDefinition();
    }
    logger.info("Setting up data model for : " + title);

    FactSet factSet = new FactSetImpl(aspectModel);      

    Networks networks = store.getNetworks(linkRole,arcrole);
    for (Network network : networks){

    if (network.isRoot((String) network.getRootFragmentIndices().toArray())){ ;
    parsePresentation(factSet, "", (Concept)network.getRootFragments().get(0),  new Double(0.0), linkRole, arcrole, org.xbrlapi.utilities.Constants.StandardLabelRole,"+");
    i++;
    }

    }

    } catch (Exception e) {

    e.printStackTrace();
    }
       
    }

    } catch (XBRLException e) {

    e.printStackTrace();
    } catch (Exception e) {

    e.printStackTrace();
    }
      }

    It was my first step to get to know the Xbrl-API technology nearer.

    I ´continuing to explore it.

    Regards
    Virgo

     

Log in to post a comment.