w3c / w3c/mathml

MathML-Next and HTTP POST

Open
#74 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement MathML-Next
Dominant language
HTML
Stars
82
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Introduction

How can resources referenced by <annotation> and <annotation-xml> elements be retrieved utilizing HTTP POST? How can we provide the annotation data of mathematical expressions as input to such resources and services?

In the discussion below, MathML4 syntactic options are presented with which to provide mathematical expressions’ annotation data, e.g. semantic content, as data when utilizing HTTP POST to access indicated resources and services.

Comments and discussion are welcomed.

Encapsulating Third-party Services with PHP Scripts

Let us consider a third-party service at https://www.thirdparty.com/needs-mmlc-data-in-post.php. The service requires a mathematical expression’s semantic content as input and it returns some or all of the mathematical expressions’ derivations in some XML-based format to be determined.

Before exploring <annotation> and <annotation-xml> elements which can access such resources utilizing HTTP POST, the scenario’s solution space includes encapsulating the third-party service. A server-side PHP script, e.g. “derivation.php”, could load a mathematical expression’s semantic content and utilize it to access the third-party service to then return the service’s output to end-users.

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="derivation.php?equation=eq1" />
  </semantics>
</math>

Posting Mathematical Expressions to Resources and Services

Let us again consider a third-party service at https://www.thirdparty.com/needs-mmlc-data-in-post.php. The service requires a mathematical expression’s semantic content as input and it returns some or all of the mathematical expressions’ derivations in some XML-based format to be determined.

In the approach to be considered, end-users are desired to access the third-party service themselves should they desire to explore some or all of the derivations of a mathematical expression.

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="https://www.thirdparty.com/needs-mmlc-data-in-post.php" />
  </semantics>
</math>

Firstly, we would like to be able to indicate that the resource or service is to be accessed via HTTP POST. This could be achieved via a method attribute (see also: HTML5 <form> element).

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml method="post" definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="https://www.thirdparty.com/needs-mmlc-data-in-post.php" />
  </semantics>
</math>

Next, we would like to be able to indicate the encoding type for the POST. This could be achieved via an enctype attribute (see also: HTML5 <form> element).

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml method="post" enctype="multipart/form-data" definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="https://www.thirdparty.com/needs-mmlc-data-in-post.php" />
  </semantics>
</math>

Next, we would like to be able to indicate the character encoding for the POST. This could be achieved via an accept-charset attribute (see also: HTML5 <form> element).

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml method="post" enctype="multipart/form-data" accept-charset="utf-8" definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="https://www.thirdparty.com/needs-mmlc-data-in-post.php" />
  </semantics>
</math>

Next, we would like to be able to refer to a semantic annotation by id to refer to the annotation’s data. We can add an id attribute to the expression’s semantic annotation.

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml id="eq1-semantics" name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml method="post" enctype="multipart/form-data" accept-charset="utf-8" definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="https://www.thirdparty.com/needs-mmlc-data-in-post.php" />
  </semantics>
</math>

Finally, we would like to be able to indicate that a POST parameter has the value of the expression’s semantics. An HTTP POST parameter, “content”, is desired to have as its value the data referred to by the semantic annotation with the id of “eq1-semantics”. That is, to access the service at https://www.thirdparty.com/needs-mmlc-data-in-post.php, a browser must first download the resource of type application/mathml-content+xml from the relative URL “eq1.mmlc” to pass to the service as a POST parameter named “content”.

There are a number of possible syntactic approaches.

Approach 1: A data Attribute
data="content={get-annotation-data-by-id('eq1-semantics')}"
<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml id="eq1-semantics" name="contentequiv" encoding="application/mathml-content+xml" src="eq1.mmlc" />
    <annotation-xml method="post" enctype="multipart/form-data" accept-charset="utf-8" data="content={get-annotation-data-by-id('eq1-semantics')}" definitionURL="http://www.example.com/" cd="cd" name="derivation" encoding="application/tbd+xml" src="https://www.thirdparty.com/needs-mmlc-data-in-post.php" />
  </semantics>
</math>

Advantages of a data attribute approach – utilizing a string interpolation syntax resembling that of a possible pattern attribute (see: https://github.com/mathml-refresh/mathml/issues/68) – include that values could be specified for multiple POST parameters.

Obtaining Presentation from Content and Content from Presentation

The following example showcases the expressiveness with which to articulate that presentation content can be obtained from semantic content.

<math id="eq1">
  <semantics>
    <annotation-xml encoding="application/mathml-presentation+xml" method="post" enctype="multipart/form-data" accept-charset="utf-8" src="math-c2p.php" data="content={get-annotation-data-by-id('eq1-semantics')}&amp;language={lang}&amp;notation={notation}" />
    <annotation-xml id="eq1-semantics" encoding="application/mathml-content+xml" src="eq1.mmlc" />
  </semantics>
</math>

The following example showcases the expressiveness with which to articulate that semantic content can be obtained from presentation content.

<math id="eq1">
  <semantics>
    <annotation-xml id="eq1-presentation" encoding="application/mathml-presentation+xml" src="eq1.mmlp" />
    <annotation-xml encoding="application/mathml-content+xml" method="post" enctype="multipart/form-data" accept-charset="utf-8" src="math-p2c.php" data="presentation={get-annotation-data-by-id('eq1-presentation')}" />
  </semantics>
</math>

Conclusion

In the discussion above, MathML4 syntactic options were presented with which to access resources via HTTP POST. Syntactic options were also presented with which to provide the annotation data of mathematical expressions, e.g. semantic content, to such resources and services.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by reviewing the proposed MathML annotation-xml syntax and its HTTP POST examples, then determine whether the project has an established specification or test location for new attributes. Done would require a resolved design and corresponding specification and conformance coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, php
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.