Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get attribute value using the <fx-output> element #287

Open
daliboris opened this issue Sep 13, 2024 · 5 comments
Open

Unable to get attribute value using the <fx-output> element #287

daliboris opened this issue Sep 13, 2024 · 5 comments

Comments

@daliboris
Copy link

I'm trying to get the value of the attribute using the <fx-output> element.

Sample input data:

<item xml:id="rochotius-comoedia.comm.000005">
 <app from="#rochotius-comoedia.comm.000005.start" n="5">
  <note>
   <cit>
    <quote type="paraphrase" subtype="equal">Senex </quote>
   </cit>
   <cit>
    <quote type="paraphrase" subtype="equal"> Senex</quote>
   </cit>
  </note>
 </app>
</item>

Each of the the following statement returns undefined in the output (HTML page):

<fx-output ref="app//cit" value="quote/@type"></fx-output>
<fx-output ref="app//quote" value="@type"></fx-output>
<fx-output ref="app//quote" value="./@type"></fx-output>

Two following approaches return the value, but the result contains only one item while the source contains two elements with the @type attribute.

<fx-output ref="app//quote/@type"></fx-output>
<fx-output ref="for $quote in app//quote return $quote/@type"></fx-output>

The <fx-repeat> element with template expressions returns the expected result: two values of the @type attribute:

<fx-repeat ref="app/note/cit/quote">
  <template>
   <span>{./@type}</span>
  </template>
</fx-repeat>

Is it possible to use XPath for retrieving attribute value of the element from within @value attribute of the <fx-output> element?

I know that for repeated elements using <fx-repeat> element makes sense, but even if the source <note> element contains only one <cit>/<quote> sequence the <fx-output ref="app//quote" value="./@type" /> or
<fx-output ref="app/note/cit/quote" value="./@type" /> returns undefined.

@JoernT
Copy link
Contributor

JoernT commented Sep 16, 2024

@daliboris It's not 100% clear to me what you're trying to achieve/expecting - output both occurrences of @type?

We'll have a look at this.

@DrRataplan
Copy link
Collaborator

DrRataplan commented Sep 16, 2024 via email

@JoernT
Copy link
Contributor

JoernT commented Sep 17, 2024

The XForms spec says that controls (including output) use 'single item binding':

When a binding is defined as a Single Item Binding then the First-item rule is applied: if a binding selects a sequence of size greater than 1, the first item in the sequence is used.

Further there not a single example using both ref and value at the same time though i also don't see it to be explicitly denied.

Though we don't necessarily need to follow the spec in all cases i guess it makes sense here to restrict controls to 'single item bindings' - the only exception (of course) is the repeat element.

Therefore if you want to output multiple nodes/values you'll have to use fx-repeat or maybe have your own custom function for that.

@JoernT
Copy link
Contributor

JoernT commented Sep 20, 2024

@daliboris could you please give more context about your use case? If we know what you're trying to achieve we can help to work out a solution but we need to clarify if this is really an issue or otherwise needs addressing/working out a solution.

@JoernT
Copy link
Contributor

JoernT commented Oct 2, 2024

I'll leave the ticket open for another week or so but i don't see an issue here though i might be missing something. If you can please elaborate on the problem? Is it still a problem? If so, we can work out a proper solution if we have a concrete use case to fulfill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants