Yep, xs:include (and xs:import) are both similar in concept to #includes in C. These two elements allow the top-level elements/types/groups/etc. that are defined in the included/imported schema to be used in the parent schema. The included/imported schema still needs to be a valid schema and cannot contain components with the same, but otherwise works like you might expect. It also allows nested of includes and even cycles are allowed.
The difference between xs:include and xs:import--the xs:include element should be used when the schema you're including has the same targetNamespace as the parent, or if it has no targetNamespace. On the other hand, xs:import should be used when the namespace of the imported schema differs from the parent. The MIL-STD-2045 schema has a good example of these two elements: https://github.com/DFDLSchemas/mil-std-2045/blob/master/src/main/resources/com/tresys/mil-std-2045/xsd/milstd2045_application_header.dfdl.xsd#L29-L31 In this schema you can see that xs:include is used to bring in some common simpleType definitions that are used throughout the schema (e.g. tIntField, tHexBinary). The milstd2045.common.dfdl.xsd schema is in the same targetNamespace as the application header schema, so xs:include is used. This schmema uses xs:import to bring in an internal.dfdl.xsd schema and a message_size.dfdl.xsd schema. xs:import is necessary here because those two schemas are defined in different targetNamespaces. Also note that DFDL properties are scoped to the schema file. So, for example, if you define an element E in schema B.dfdl.xsd, and you include B.dfdl.xsd in A.dfdl.xsd, element E will use the DFDL properties defined in B.dfdl.xsd and not those in A.dfdl.xsd. Using xs:includes and/or xs:import is definitely a great way to break up a large schema. On 09/20/2018 06:28 PM, Jim Welch wrote: > I have been googling for an answer. What does the <xs:include > schemaLocation="file.dfdl.xsd" /> actually do? Does it work like C++, just > reads > the file like it is part of the parent file or are there rules? Does it need > to > be a complete schema? My current schema is 3,000 lines long. I want to break > it up. >
