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

Question: using a backslash in xspec #1926

Closed
jbriner-pearson opened this issue May 21, 2024 · 4 comments
Closed

Question: using a backslash in xspec #1926

jbriner-pearson opened this issue May 21, 2024 · 4 comments
Labels

Comments

@jbriner-pearson
Copy link

I have a scenario that contains this:

<x:call template="cxml">
                    <x:param name="content">
                        <qti-assessment-item>
                            <qti-item-body>
                                <div class="qti-layout-row"><div class="qti-layout-col6 qti-layout-offset3"><qti-choice-interaction>
                                    <qti-prompt>
                                        <x:text>dilation </x:text><qti-math data-latex="J^{\prime}"></qti-math>
                                    </qti-prompt>
                                    <qti-simple-choice identifier="A">Choice A</qti-simple-choice>
                                </qti-choice-interaction>
                                </div></div>
                            </qti-item-body>
                        </qti-assessment-item>
                    </x:param>
                </x:call>

The issue is the backslash on \prime. I cannot get that into the input. It works fine when the xslt transform (Saxon) is running. However, when I run xspec, I get errors. I have tried & #x5C; and \\, also without luck. Suggestions? I have a lot more of these to add. However, if I can get this to work, I am sure that I can get the others.

TIA

@galtm
Copy link
Collaborator

galtm commented May 26, 2024

Hi,

The short answer is to double the curly braces in your content's attribute values (like data-latex="J^{{\prime}}") when the expression inside the braces isn't meant to be XPath.

Longer answer:

XSpec thinks the attribute data-latex="J^{\prime}" in your provided parameter value is an attribute value template and sets things up so that Saxon will evaluate the part inside the curly braces as an XPath expression. The error occurs because \prime is not a valid XPath expression. In your case, I'm inferring that your intention is for the attribute value to store LaTeX, not text with an embedded XPath expression. Doubling the curly braces tells the XSLT processor to replace {{ with {, replace }} with }, and not evaluate the text inside the braces. XSpec won't double the curly braces internally on your behalf, because it doesn't know if you want the expression inside to be evaluated or taken literally.

As for why the attribute doesn't cause a problem when you run your XSLT transformation in Saxon, your XSLT probably has nothing in it that interprets the value of data-latex as an attribute value template, so the misinterpretation just doesn't arise.

I hope this helps!

@jbriner-pearson
Copy link
Author

Thank you for your explanation. It was very helpful.

@galtm galtm added the question label Jun 4, 2024
@galtm
Copy link
Collaborator

galtm commented Jun 4, 2024

Happy to help. I'll mark this issue complete.

@galtm galtm closed this as completed Jun 4, 2024
@galtm
Copy link
Collaborator

galtm commented Jun 11, 2024

@jbriner-pearson , I should have also mentioned that an alternative solution is to make XSpec load the XML content from an external XML file by using the href attribute (and select as well, if you want to select a portion of a document) in <x:context>. The XPath evaluation behavior I described earlier happens only when the XML content is embedded directly in the XSpec file.

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

No branches or pull requests

2 participants