String fpath = url.toExternalForm();
if (paths.add(fpath)) {
try {
// access the included binding as input stream
UnmarshallingContext ictx = new UnmarshallingContext();
ictx.setDocument(url.openStream(), null);
// get basic name and package information from binding
ictx.parseToStartTag(URI_ELEMENTS, BINDING_ELEMENT);
String fname = org.jibx.binding.Utility.fileName(path);
String name = ictx.attributeText(URI_ATTRIBUTES, BINDING_NAME,
org.jibx.binding.Utility.bindingFromFileName(fname));
int major = ictx.attributeInt(URI_ATTRIBUTES,
BINDING_MAJORVER, 0);
int minor = ictx.attributeInt(URI_ATTRIBUTES,
BINDING_MINORVER, 0);
String tpack = ictx.attributeText(URI_ATTRIBUTES,
BINDING_PACKAGE, null);
boolean direct = ctx.attributeBoolean(URI_ATTRIBUTES,
INCLUDE_PRECOMPILED, false);
if (direct && tpack == null) {
throw new JiBXException("package attribute is required for precompiled binding");
}
if (direct) {
// load and add binding factory for precompiled binding
factory = BindingDirectory.getFactory(name, tpack,
ClassFile.getClassLoader());
nsxlate = bdef.addPrecompiledBinding(factory, major, minor);
}
// unmarshal namespaces (to apply to these mappings, only)
ictx.parsePastStartTag(URI_ELEMENTS, BINDING_ELEMENT);
ArrayList nss = new ArrayList(nslist);
while (ictx.isAt(URI_ELEMENTS, NAMESPACE_ELEMENT)) {
nss.add(unmarshalNamespace(ictx));
}
// process any format definitions (for global context)
precomp = precomp || direct;
unmarshalFormats(ictx, precomp, bdef.getDefinitionContext());
// check for nested includes
while (ictx.isAt(URI_ELEMENTS, INCLUDE_ELEMENT)) {
unmarshalInclude(ictx, precomp, bdef, url, nss, paths,
factory, nsxlate);
}
// process all mappings defined in included binding