Insert via Select1?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Insert via Select1?

Jim Logan-3
Does anyone know a way to select a name from a list and then insert the corresponding complex structure into an instance document?

For example, I have a list of authorities like this:
            <xforms:instance id="authorities">
                <defaultviewpoint:default_root>
                    <auth:authority
                        mdp:id="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#Cory">
                        <rdfs:label>Cory</rdfs:label>
                    </auth:authority>
                    <auth:authority
                        mdp:id="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#Jim">
                        <rdfs:label>Jim</rdfs:label>
                    </auth:authority>
                </defaultviewpoint:default_root>
            </xforms:instance>
and I need the user to select one of them by name on the form. (E.g., by typing "Jim" or "Cory".) When the user selects one, I need to insert its entire <auth:authority/> block into the main instance document, right above any existing <auth:authority/> block. It needs to be surrounded by another XML entity in the main instance document, called "<auth:responsible_party>".

The main instance looks something like this:
<defaultviewpoint:default_root
    xmlns:DefaultViewpoint="http://www.modeldriven.org/2008/ArchitectureOntology/DefaultViewpoint.owl#"
    xmlns:mdp="http://www.modeldriven.org/2007/schema/ModelDrivenProfile.xsd"
    xmlns:v="http://www.modeldriven.org/2008/ArchitectureOntology/Versioning.owl#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:auth="http://www.modeldriven.org/2008/ArchitectureOntology/Authority.owl#"
    xmlns:SampleVersions="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#">
    <v:unstructured_data_asset
        mdp:id="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#CowFile">
        <!--Get  ID=http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#CowFile-->
        <rdfs:label>Cow File</rdfs:label>
        <v:current_version>
            <v:data_asset_version
                mdp:id="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#CowFileVersion2">
                <!--Get  ID=http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#CowFileVersion2-->
                <rdfs:label>v2</rdfs:label>
            </v:data_asset_version>
        </v:current_version>

        <!-- Insert here so it looks just like the one below -->
        <auth:responsible_party>
            <auth:authority
                mdp:id="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#Cory">
                <!--Get  ID=http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#Cory-->
                <rdfs:label>Cory</rdfs:label>
            </auth:authority>
        </auth:responsible_party>

        <v:contained_in>
            <v:data_asset_container
                mdp:id="http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#CowFolder">
                <!--Get  ID=http://www.modeldriven.org/2008/ArchitectureOntology/Samples/SampleVersions.owl#CowFolder-->
            </v:data_asset_container>
        </v:contained_in>
    </v:unstructured_data_asset>
</defaultviewpoint:default_root>

I want to use an incremental "select1" control to choose which one to insert, but I'm not sure how to grab the chosen <auth:authority> by its "mdp:id" key and do the insert.

Has anyone done anything like this?

Thanks,
-Jim



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Insert via Select1?

fl.schmitt(ops-users)
Hi Jim,

> and I need the user to select one of them by name on the form. (E.g., by
> typing "Jim" or "Cory".) When the user selects one, I need to insert its
> entire <auth:authority/> block into the main instance document, right
> above any existing <auth:authority/> block. It needs to be surrounded by
> another XML entity in the main instance document, called
> "<auth:responsible_party>".

i think the easiest solution would be to put an empty
"responsible_party" fragment containing the nested authority structure
into the main instance.

Then, you could bind the select1 eigther to the @mdp:id or to the
rdfs:label so that this value is set when the user selects one of the
entries. The remaining value could be calculated using a binding,
because it depends on the selected value. For example:

<xforms:bind
ref="instance('main-instance')/v:unstructured_data_asset/auth:responsible_party/auth:authority/rdfs:label"
calculate="instance('authorities')/auth:authority/rdfs:label[
     ../@mdp:id eq
instance('main-instance')//v:unstructured_data_asset/auth:responsible_party/auth:authority/@mdp:id
]" />

I've attached an example.


HTH
florian



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

asset.xhtml (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: Insert via Select1?

Jim Logan-3
Florian Schmitt wrote:

>
> i think the easiest solution would be to put an empty
> "responsible_party" fragment containing the nested authority structure
> into the main instance.
>
> Then, you could bind the select1 eigther to the @mdp:id or to the
> rdfs:label so that this value is set when the user selects one of the
> entries. The remaining value could be calculated using a binding,
> because it depends on the selected value. For example:
>
> <xforms:bind
> ref="instance('main-instance')/v:unstructured_data_asset/auth:responsible_party/auth:authority/rdfs:label"
>
> calculate="instance('authorities')/auth:authority/rdfs:label[
>     ../@mdp:id eq
> instance('main-instance')//v:unstructured_data_asset/auth:responsible_party/auth:authority/@mdp:id
>
> ]" />
>
> I've attached an example.
Thank you, Florian!

-Jim



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws