Sharebar?

Inline Elements in itemBody

Inline Elements in itemBody

Creating the JAXBElements from 1EdTech QTI v2.1 and an input stream is giving us issues with regards to inline elements, such as <strong>, <sub>, and <span>. When unmarshalling from the input stream, we are getting these elements back as block elements, not inline elements, and this is creating additional spaces in the text. Are there any known issues with these inline elements, or is there a suggested way to treat these elements when reading from an input stream? 

 

Thanks,

Aaron Brooks

Hi Aaron,

Hi Aaron,

    It would be useful to have a bit more information, hopefully involving a concrete example, to help in identifying what exact problem you are experiencing.

    For example you say you are using JAXB to parse QTI 2.1 XML and having elements treated as block elements that you would expect to be inline elements. However I don't think that JAXB has a concept that these elements would be treated as inline elements in HTML.

   When you say it is causing additional spaces in the text, is that in e.g. a serialization of the result of the parsing of the QTI XML, or do you mean when you later render the resulting serialization in a browser that the browser treats these span, sub etc. elements as if they were block HTML elements rather than treating them as if they are HTML inline elements (as a span element would be by default in HTML)?

   If it is the latter then I would guess that there is no issue with parsing etc, but that when you generate the webpage which gets sent to the browser that output still retains the QTI namespace definition somewhere.

   If you see 
<item xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">
<span>What is the common name for liquid H<sub>2</sub>O ?<span>
</item>

  At first glance this appears to have a HTML span and sub element in it, but appearances are deceiving as it is only a HTML span element if it is in the HTML namespace. By default in a web page everything would be assumed to be in the HTML namespace and you don't have to think about namespaces unless you have inline SVG or MathML elements in your page.

  However the span and sub elements above are not HTML elements at all, they are XML elements in the QTI namespace (http://www.imsglobal.org/xsd/imsqti_v2p1) which just happen to have the same tagName (localName) as the HTML elements you are used to. That's because the item element had an xmlns attribute which set a default namespace of the QTI namespace for itself and all it's children.

  As a HTML browser doesn't understand QTI XML elements it renders them all in the same way, it presumes that they are all block elements. 

  You could probably use a JAX Transformer to transform the XML to HTML (which should also transform the XML style empty elements like <hr/> which browsers don't like to the HTML style <hr>) using an approach similar to that used in this class http://www.javased.com/index.php?source_dir=coala/modules/coala-communication/src/main/java/org/openehealth/coala/transformer/XmlTransformer.java or alternatively add a SAXFilter to remove the namespace definitions.

   All the best,

         Padraig