Instanced in XML with two select1's?

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

Instanced in XML with two select1's?

aceospade
Say you have an XML document that is instanced in. <xf:instance
src="document.xml" xmlns="" /> This also has two separate instances in
the model. Later down in the XForm you have a select1 which references
the XML document. Would it be possible to have two separate instances
reference the same XML document on the same form? There would also be
two separate select1's that would have a drop down menu which you show
values when the item was clicked.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
Hi,

Your question below is confusing to me.  You are saying that you have 3
instances in a model...document.xml loaded externally and two other
ones.  I get that.  Then you mention a select1 that references that
document, so I assume that you mean that the select1 is bound to a node
inside document.xml?  Then you say, "Would it be possible to have two
separate instances reference the same XML document on the same form?"
This is where you lost me.  One instance document may not reference
another instance document if that is what you are asking.  However, if
by 'instances' you mean separate instances of select1, then yes, you can
certainly have two select1's on the same form that reference separate
instance documents.

Or are you asking whether you can have a select1 that you can use to
select which instance that other select1's are bound to?  You probably
can, but you'd have to use JS to pull it off.

Please clarify a little bit and then I can go into more detail.

Thanks,
--Aaron

aceospade wrote:
> Say you have an XML document that is instanced in. <xf:instance
> src="document.xml" xmlns="" /> This also has two separate instances in
> the model. Later down in the XForm you have a select1 which references
> the XML document. Would it be possible to have two separate instances
> reference the same XML document on the same form? There would also be
> two separate select1's that would have a drop down menu which you show
> values when the item was clicked.
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
There is one instance where the xml document is referenced in. Then
later in the body of the form the select1 references it once. Can you
have two select1's that reference the same instance? There would be
two of the same drop down list but would show different data from the
lists. I hope this helps some.
Thanks
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
Hi Matthew,

I'm getting closer to understanding what you mean, I think.

You have one instance like:

<xf:model>
   <xf:instance xmlns=""?
     <root>
       <bounddata></bounddata>
       <data>my first item</data>
       <data>my second item</data>
       <data>my third item</data>
       <data>my fourth item</data>
       <data>my fifth item</data>
       <moredata>my first additional item</moredata>
       <moredata>my second additional item</moredata>
       <moredata>my third additional item</moredata>
       <moredata>my fourth additional item</moredata>
       <moredata>my fifth additional item</moredata>
     </root>
   </xf:instance>
</xf:model>

...

<xf:select1 ref="bounddata">
   <xf:itemset nodeset="/root/data">
     <xf:label ref="."/>
     <xf:value ref="."/>
   </xf:itemset>
</xf:select1>

<xf:select1 ref="bounddata">
   <xf:itemset nodeset="/root/moredata">
     <xf:label ref="."/>
     <xf:value ref="."/>
   </xf:itemset>
</xf:select1>

Is that what you meant?  Two select1's bound to the same node but each
with a different set of items?

--Aaron

aceospade wrote:
> There is one instance where the xml document is referenced in. Then
> later in the body of the form the select1 references it once. Can you
> have two select1's that reference the same instance? There would be
> two of the same drop down list but would show different data from the
> lists. I hope this helps some.
> Thanks
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
Yes that is it! But what I wanted to know was could you have the two
select1's reference the same data and have both of them work at the
same time? Like...

<xf:select1 ref="bounddata">
   <xf:itemset nodeset="/root/data">
     <xf:label ref="."/>
     <xf:value ref="."/>
   </xf:itemset>
</xf:select1>

<xf:select1 ref="bounddata">
   <xf:itemset nodeset="/root/data">
     <xf:label ref="."/>
     <xf:value ref="."/>
   </xf:itemset>
</xf:select1>
is that possible or does the XForms get confused somewhere. Another
question was if you had a switch/case could it be done on a separate
case that references the same instance? Thank you for you insight.
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
Hi Matthew,

Answers below.

aceospade wrote:

> Yes that is it! But what I wanted to know was could you have the two
> select1's reference the same data and have both of them work at the
> same time? Like...
>
> <xf:select1 ref="bounddata">
>    <xf:itemset nodeset="/root/data">
>      <xf:label ref="."/>
>      <xf:value ref="."/>
>    </xf:itemset>
> </xf:select1>
>
> <xf:select1 ref="bounddata">
>    <xf:itemset nodeset="/root/data">
>      <xf:label ref="."/>
>      <xf:value ref="."/>
>    </xf:itemset>
> </xf:select1>
> is that possible or does the XForms get confused somewhere.

That will work fine.  XForms should not get confused.  When you select
an item from one of them, the other's selection will change, of course.

> Another
> question was if you had a switch/case could it be done on a separate
> case that references the same instance? Thank you for you insight.

Sure you can.  The actual case id's will have to be different so that we
can tell which one to toggle.  But referencing the same node from
different controls in different places is definitely one of the
strengths of xforms.


--Aaron
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
So you can have an exact replica of a select1 right underneath and it
will still work? The data would change sure but if the data for the
select1 was referenced in from an xml document that would work as
well? Thanks again for taking the time to reply. I'm still a Newbie!
Matthew


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
In reply to this post by Aaron Reed
I have successfully gotten the multiple select1's to work when the
data is in the model itself but, what about when the data is
referenced in? When you <xf;Instance src=document.xml />? Would that
still be able to be done?
Thanks again,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
Hi Matthew,

If you have <xf:instance src=document.xml />, that is little different
that having:

<xf:instance>
   <root>
     <data/>
     ...
     <data17/>
   </root>
</xf:instance>

assuming document.xml contains <root><data/>....<data17/></root>.  All
the xforms processor does is get the contents of the @src document (in
this case document.xml) or the inline instance data (if @src is not
present), clone the contents into an in memory document containing the
instance data and from then on all the controls are bound to this in
memory document.  So it really doesn't matter where the data comes from
whether inline or from a document specified in @src.

--Aaron

aceospade wrote:
> I have successfully gotten the multiple select1's to work when the
> data is in the model itself but, what about when the data is
> referenced in? When you <xf;Instance src=document.xml />? Would that
> still be able to be done?
> Thanks again,
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
Yeah I see where it doesn't matter where the data comes from, but the
question is when you reference in a document and have a select1 for
the options. Could you have two of the same exact select1's that would
reference in from the same @src and both of them still function?
Thank you for taking the time,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
As far as I understand your question, yes.  Since we seem to agree on
the fact that it doesn't matter whether instance data is initialized via
inline data in an xf:instance or via @src on an xf:instance, then your
question becomes could two of the same exact select1's be bound to the
same instance data.  And that answer to that is yes.

--Aaron

aceospade wrote:
> Yeah I see where it doesn't matter where the data comes from, but the
> question is when you reference in a document and have a select1 for
> the options. Could you have two of the same exact select1's that would
> reference in from the same @src and both of them still function?
> Thank you for taking the time,
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
I guess that is the problem then because I haven't gotten the part
with the same exact select1's bound to the same instance data to work
right yet and I was getting confused on that. Would you have to change
anything? I'm not real sure how that would be done.  So technically
this would work?
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xf="http://www.w3.org/2002/xforms"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">
<head>
<title>Star Wars Movies</title>
<xf:model id="MovieModel">
        <xf:instance id="movies" xmlns="">
                <data>
                        <Movie>
                                <Title id="A New Hope" />
                                <Release>1977</Release>
                                <Director>George Lucas</Director>
                                <Episode>IV</Episode>
                                <Characters>Luke, Leia, Han, Chewbacca</Characters>
                        </Movie>

                        <Movie>
                                <Title id="Empire Strikes Back" />
                                <Release>1980</Release>
                                <Director>George Lucas</Director>
                                <Episode>V</Episode>
                                <Characters>Luke, Leia, Darth Vader, Lando</Characters>
                        </Movie>
                </data>
        </xf:instance>
    <xf:instance id="selected-movie" xmlns="">
        <movie-id xmlns="">A New Hope</movie-id>
    </xf:instance>
</xf:model>
</head>
<body>
<xf:select1 ref="instance('selected-movie')">
                    <xf:label>
                        <b>Film: </b>
                    </xf:label>
                    <xf:itemset nodeset="instance('movies')/Movie/
Title/@id">
                        <xf:label ref="."/>
                        <xf:value ref="."/>
                    </xf:itemset>
                </xf:select1>
<xf:group ref="instance('movies')/Movie[Title/@id = instance('selected-
movie')]"
                        id="group-repeat">
                    <dl>
                        <dt><b>Title: </b>
                            <xf:output ref="Title/@id"/>
                        </dt>
                        <dt><b>Release: </b>
                            <xf:output ref="Release"/>
                        </dt>
                        <dt><b>Director: </b>
                            <xf:output ref="Director"/>
                        </dt>
                        <dt><b>Episode: </b>
                            <xf:output ref="Episode"/>
                        </dt>
                        <dt><b>Characters: </b>
                            <xf:output ref="Characters"/>
                        </dt>
                    </dl>
                   </xf:group>
<xf:select1 ref="instance('selected-movie')">
                    <xf:label>
                        <b>Film: </b>
                    </xf:label>
                    <xf:itemset nodeset="instance('movies')/Movie/
Title/@id">
                        <xf:label ref="."/>
                        <xf:value ref="."/>
                    </xf:itemset>
                </xf:select1>
<xf:group ref="instance('movies')/Movie[Title/@id = instance('selected-
movie')]"
                        id="group-repeat">
                    <dl>
                        <dt><b>Title: </b>
                            <xf:output ref="Title/@id"/>
                        </dt>
                        <dt><b>Release: </b>
                            <xf:output ref="Release"/>
                        </dt>
                        <dt><b>Director: </b>
                            <xf:output ref="Director"/>
                        </dt>
                        <dt><b>Episode: </b>
                            <xf:output ref="Episode"/>
                        </dt>
                        <dt><b>Characters: </b>
                            <xf:output ref="Characters"/>
                        </dt>
                    </dl>
                   </xf:group>
                <xf:submit submission="submit">
                        <xf:label> Save </xf:label>
                </xf:submit>
</body>
</html>
Thanks,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
In order to get this to work what I did was give each select1 it's own
selected movie to go from and it worked just fine for me. Thanks for
all of you insight.
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
In reply to this post by aceospade
This works for me, but since they are bound to the same node, they each
change when the other changes like I had noted before.  I assumed that
is what you wanted.

--Aaron

aceospade wrote:

> I guess that is the problem then because I haven't gotten the part
> with the same exact select1's bound to the same instance data to work
> right yet and I was getting confused on that. Would you have to change
> anything? I'm not real sure how that would be done.  So technically
> this would work?
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:ev="http://www.w3.org/2001/xml-events"
> xmlns:xforms="http://www.w3.org/2002/xforms"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <head>
> <title>Star Wars Movies</title>
> <xf:model id="MovieModel">
> <xf:instance id="movies" xmlns="">
> <data>
> <Movie>
> <Title id="A New Hope" />
> <Release>1977</Release>
> <Director>George Lucas</Director>
> <Episode>IV</Episode>
> <Characters>Luke, Leia, Han, Chewbacca</Characters>
> </Movie>
>
> <Movie>
> <Title id="Empire Strikes Back" />
> <Release>1980</Release>
> <Director>George Lucas</Director>
> <Episode>V</Episode>
> <Characters>Luke, Leia, Darth Vader, Lando</Characters>
> </Movie>
>                 </data>
> </xf:instance>
>     <xf:instance id="selected-movie" xmlns="">
>         <movie-id xmlns="">A New Hope</movie-id>
>     </xf:instance>
> </xf:model>
> </head>
> <body>
> <xf:select1 ref="instance('selected-movie')">
>                     <xf:label>
>                         <b>Film: </b>
>                     </xf:label>
>                     <xf:itemset nodeset="instance('movies')/Movie/
> Title/@id">
>                         <xf:label ref="."/>
>                         <xf:value ref="."/>
>                     </xf:itemset>
>                 </xf:select1>
> <xf:group ref="instance('movies')/Movie[Title/@id = instance('selected-
> movie')]"
>                         id="group-repeat">
>                     <dl>
>                         <dt><b>Title: </b>
>                             <xf:output ref="Title/@id"/>
>                         </dt>
>                         <dt><b>Release: </b>
>                             <xf:output ref="Release"/>
>                         </dt>
>                         <dt><b>Director: </b>
>                             <xf:output ref="Director"/>
>                         </dt>
>                         <dt><b>Episode: </b>
>                             <xf:output ref="Episode"/>
>                         </dt>
>                         <dt><b>Characters: </b>
>                             <xf:output ref="Characters"/>
>                         </dt>
>                     </dl>
>                    </xf:group>
> <xf:select1 ref="instance('selected-movie')">
>                     <xf:label>
>                         <b>Film: </b>
>                     </xf:label>
>                     <xf:itemset nodeset="instance('movies')/Movie/
> Title/@id">
>                         <xf:label ref="."/>
>                         <xf:value ref="."/>
>                     </xf:itemset>
>                 </xf:select1>
> <xf:group ref="instance('movies')/Movie[Title/@id = instance('selected-
> movie')]"
>                         id="group-repeat">
>                     <dl>
>                         <dt><b>Title: </b>
>                             <xf:output ref="Title/@id"/>
>                         </dt>
>                         <dt><b>Release: </b>
>                             <xf:output ref="Release"/>
>                         </dt>
>                         <dt><b>Director: </b>
>                             <xf:output ref="Director"/>
>                         </dt>
>                         <dt><b>Episode: </b>
>                             <xf:output ref="Episode"/>
>                         </dt>
>                         <dt><b>Characters: </b>
>                             <xf:output ref="Characters"/>
>                         </dt>
>                     </dl>
>                    </xf:group>
>                 <xf:submit submission="submit">
> <xf:label> Save </xf:label>
> </xf:submit>
> </body>
> </html>
> Thanks,
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

Aaron Reed
In reply to this post by aceospade
Good, I'm glad that you got it working to your satisfaction!
--Aaron

aceospade wrote:
> In order to get this to work what I did was give each select1 it's own
> selected movie to go from and it worked just fine for me. Thanks for
> all of you insight.
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Instanced in XML with two select1's?

aceospade
No I didn't want both of them to change. That is why I added another
selected-movie and changed that to a different movie. Then changed the
same for the group of details and then that is what I originally
wanted. For the most par tit is working to my satisfaction I just want
to keep pushing the envelope. I'm not real sure how I would sum( ) up
all of the hours watched with the hours put I guess towards watching
them. You have been a great help and I thank you very much.
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms