Re: XPath nodeset filtering by a constant element name defined in another expression (value of XPath)

Rhydian Morris <RMorris@focus-solutions.co.uk> wrote:
> I think your XPath should be something like this
> 
>  <xforms:itemset 
> 
nodeset="instance('scratchpad-locations-work-type')/SubstationDistributionWo
> rkType/AllowedWorkType/*[name() =
> instance('work_order')/Location/SubstationCode][text() = 'true']">

Thanks!

I was trying to do "AllowedWorkType/*/local-name()=" and 
"AllowedWorkType/child::local-name()=" before as I never found any examples 
of their usage.  It makes sense in retrospect.

I've downloaded XFormation2, and I'll take a look through the examples.   My 
biggest problem with XForms is the lack of examples for doing common things 
like this.

For those who follow after, needing the same functionality:

My final results was as follows.   I changed name() to local-name() and 
"Description" to "../Description".


			    <xforms:itemset 
nodeset="instance('scratchpad-locations-work-type')/SubstationDistributionWorkType/AllowedWorkType/*[local-
name()=instance('work_order')/Location/SubstationCode][text()='true']">

			      <xforms:label ref="../Description"/>

			      <xforms:value ref="../Description"/>

			    </xforms:itemset>



> -----Original Message-----
> From: Mike Kienenberger [mailto:mkienenb@alaska.net]
> Sent: 11 March 2005 06:43
> To: www-forms@w3.org
> Subject: XPath nodeset filtering by a constant element name defined in
> another expression (value of XPath)
> 
> 
> 
> I have xml data of this form:
> 
> <SubstationDistributionWorkType>
> 
>  <AllowedWorkType>
> 
>   <Description>Annunciator</Description>
> 
>   <ARS>false</ARS>
> 
>   <BRS>true</BRS>
> 
>   <BKS>true</BKS>
> 
>   <CPS>true</CPS>
> 
>  [...]
>  </AllowedWorkType>
> </SubstationDistributionWorkType>
> 
> I want to create a select1 control showing descriptions based on whether 
the
> 
> 3-letter elements match another expression.
> 
> For example, the following works, but has "BKS" hardcoded in.
> 
>  			<xforms:select1 ref="WorkType"
> 
> 			    appearance="minimal" class="ctrl select1"
> navindex="8">
> 
> 			    <xforms:itemset 
> 
nodeset="instance('scratchpad-locations-work-type')/SubstationDistributionWo
> rkType/AllowedWorkType[BKS='true']">
> 
> 
> 			      <xforms:label ref="Description"/>
> 
> 			      <xforms:value ref="Description"/>
> 
> 			    </xforms:itemset>
> 
> 			</xforms:select1>
> 
> 
> However, instead of a constant element name of "BKS", I want to use the 
> value from the expression "instance('work_order')/Location/SubstationCode" 

> as the basis of the element name used as the filter.
> 
> I'm fairly certain that it's a matter of rewriting the filtering rather 
than
> 
> simple substitution, but I'm not sure where to go from here.
> 
> I've done similar things when I needed to compare a value (rather than an 
> element name) using this expression
> 
> <xforms:itemset 
> 
nodeset="instance('scratchpad-equipment')/SubstationEquipment/Location[Locat
> ionID=instance('work_order')/Location/SubstationCode]">
> 
> 
> 
> but I can't seem to figure out the equivalent.
> 
> Thanks,
> 
> -Mike
> 
> 

Received on Friday, 11 March 2005 14:17:49 UTC