@@ -26,42 +26,44 @@ Profile resolution takes an OSCAL profile and produces a **resolved catalog** co
2626
2727## Basic Profile Resolution
2828
29+ The `ProfileResolver` accepts file paths, URLs, or document nodes and returns an `IDocumentNodeItem` containing the resolved catalog:
30+
2931```java
3032import dev.metaschema.oscal.lib.OscalBindingContext;
3133import dev.metaschema.oscal.lib.model.Catalog;
32- import dev.metaschema.oscal.lib.model.Profile;
3334import dev.metaschema.oscal.lib.profile.resolver.ProfileResolver;
34- import dev.metaschema.databind.io.Format;
35- import dev.metaschema.databind.io.IDeserializer;
35+ import dev.metaschema.core.model.IDocumentNodeItem;
3636
3737import java.nio.file.Path;
3838
39- // Load the profile
40- OscalBindingContext context = OscalBindingContext.instance();
41- IDeserializer<Profile> deserializer = context.newDeserializer(
42- Format.JSON, Profile.class);
43- Profile profile = deserializer.deserialize(Path.of("profile.json"));
44-
45- // Resolve to catalog
39+ // Resolve a profile directly from a file path
4640ProfileResolver resolver = new ProfileResolver();
47- Catalog resolvedCatalog = resolver.resolve(profile);
41+ IDocumentNodeItem resolvedDocument = resolver.resolve(Path.of("profile.json"));
42+
43+ // Extract the catalog from the resolved document
44+ Catalog resolvedCatalog = (Catalog) resolvedDocument.getValue();
4845```
4946
5047## Resolution with Custom Document Loader
5148
52- For profiles that import external resources:
49+ For profiles that import external resources, configure a document loader :
5350
5451```java
55- import dev.metaschema.core.util.IDocumentLoader;
5652import dev.metaschema.databind.io.DefaultBoundLoader;
5753
58- // Create a document loader
59- IDocumentLoader loader = new DefaultBoundLoader(context );
54+ // Get the binding context
55+ OscalBindingContext context = OscalBindingContext.instance( );
6056
61- // Resolve with custom loader
57+ // Create a document loader with the context
58+ DefaultBoundLoader loader = new DefaultBoundLoader(context);
59+
60+ // Configure resolver with custom loader
6261ProfileResolver resolver = new ProfileResolver();
6362resolver.setDocumentLoader(loader);
64- Catalog resolvedCatalog = resolver.resolve(profile);
63+
64+ // Resolve the profile
65+ IDocumentNodeItem resolvedDocument = resolver.resolve(Path.of("profile.json"));
66+ Catalog resolvedCatalog = (Catalog) resolvedDocument.getValue();
6567```
6668
6769## Saving the Resolved Catalog
0 commit comments