I am using DHF with entity-services. I was wondering if an envelope contains multiple entity instances can I have the envelope be designed as below
<envelope xmlns="http://marklogic.com/entity-services">
<headers>
</headers>
<triples>
</triples>
<instance>
<info>
<title>target</title>
<version>1.0.0</version>
</info>
<target:target xmlns:target="http://schemas.abbvienet.com/entity/target">
....
</target>
</instance>
<instance>
<info>
<title>core</title>
<version>1.0.0</version>
</info>
<core:core xmlns:core="http://schemas.abbvienet.com/entity/core">
....
</core>
</instance>
<attachments>
</attachments>
</envelope>
Notice the 2 instance
tags for 2 instances.
Is this valid, as I was not able to find the recommendation of envelope design, like xsd
?Is this a good design of the instances in the envelope or is there a better way ? Or can I have like this
<envelope xmlns="http://marklogic.com/entity-services">
<headers>
</headers>
<triples>
</triples>
<instance>
<info>
<title>target</title>
<version>1.0.0</version>
</info>
<target:target xmlns:target="http://schemas.abbvienet.com/entity/target">
....
</target>
<core:core xmlns:core="http://schemas.abbvienet.com/entity/core">
....
</core>
</instance>
<attachments>
</attachments>
</envelope>
I want to use the es
api for canonicalizing the entity
Currently the DHF (and entity services) support a paradigm of one instance per document following the envelope pattern.
If you need the same attachments/triples/header support for multiple instances of an entity (or multiple entities) - just split them up and attach them.
Also, you really shouldn't be modifying the instance portion of the generated envelope:
<es:envelope xmlns:es="http://marklogic.com/entity-services">
<es:instance>
<es:info>
<es:title>Person</es:title>
<es:version>1.0.0</es:version>
</es:info>
<Person>
<id>1234</id>
<firstName>George</firstName>
<lastName>Washington</lastName>
<fullName>George Washington</fullName>
</Person>
</es:instance>
<es:attachments>
<person>
<pid>1234</pid>
<given>George</given>
<family>Washington</family>
</person>
</es:attachments>
</es:envelope>
But you can add information elsewhere outside the instance as needed. More information on entity services relating to your question can be found here: https://docs.marklogic.com/guide/entity-services/instances#id_67461
There is, currently, a bit of a gap between ES and DataHub that we are actively working on closing, which is why I encourage you not to modify the default instance setup and keep one instance per envelope document.