Resolution

AMF can be used to resolve parsed AML models. The generic resolution logic is available in the class Resolver.

The type of model to be resolved must be passed as an argument to the constructor. For any AML Dialect, "AML 1.0" must be passed as the argument.

Example

Java
JavaScript
package aml_org.examples;

import amf.client.AMF;
import amf.client.model.document.DialectInstance;
import amf.client.parse.Aml10Parser;
import amf.client.render.AmfGraphRenderer;
import amf.client.resolve.Resolver;

import java.util.concurrent.ExecutionException;

import static java.lang.System.out;

public class Resolving {

    //#resolving-example
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        AMF.init().get();

        AMF.registerDialect("file://aml/music/dialect/playlist.yaml").get();

        DialectInstance model = (DialectInstance) new Aml10Parser().parseFileAsync("file://aml/music/playlist1.yaml").get();

        DialectInstance resolvedModel = (DialectInstance) new Resolver("AML 1.0").resolve(model);

        String parsedJsonLd = new AmfGraphRenderer().generateString(resolvedModel).get();

        out.println(parsedJsonLd);

    }
}


var amf = require("amf-client-js");
var AMF = amf.AMF;
var Resolver = amf.Resolver;
var Aml10Parser = amf.Aml10Parser;
var AmfGraphRenderer = amf.AmfGraphRenderer;

//#resolving-example
AMF.init()
    .then(function() {
        return AMF.registerDialect("file://aml/music/dialect/playlist.yaml");
    })
    .then(function() {
        return new Aml10Parser()
            .parseFileAsync("file://aml/music/playlist1.yaml");
    })
    .then(function(unit) {
        var resolved = new Resolver("AML 1.0").resolve(unit);
        return new AmfGraphRenderer().generateString(resolved);
    })
    .then(function(jsonld) {
        console.log(jsonld)
    });

results matching ""

    No results matching ""