question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema specification in root element only

See original GitHub issue

Move all prefix declarations to the root element, or allow control over prefix setting (disable prefix insertion at the place of use).

example model:

@Serializable
@XmlSerialName("document", Namespaces.view, Namespaces.prefixView)
data class Document(
    val head: Head,
    val body: Body,
    val blocks: List<Block> = emptyList(),
    val nature: String? = null,
    val background: String? = null,
    val zoomable: Boolean? = null,
    @XmlOtherAttributes
    val other: Map<String, String> = emptyMap()
)

example structure:

    val document = Document(
        head = Head(
            variables = listOf(Variable("x", "internal"), Variable("y", "internal"),)
        ),
        body = Body(cdaTopic = "topic",
            elements = listOf(
                Div(listOf(If(condition = Expression("foo")))),
                Select(variable = "foo", elements = listOf(Select.Repeat(Repeat("test")))),
                Edit(Edit.Type.STRING, "foo"),
            )
        ),
        other = mapOf(Namespaces.xmlnsNaming.toCName() to Namespaces.naming)
    )

output:

<d:document xmlns:d="http://www.webui-ap.com/schemata/view/1.0" n:xmlns="http://www.webui-ap.com/schemata/naming/1.0">
  <d:head>
    <d:variable name="x" type="internal"/>
    <d:variable name="y" type="internal"/>
  </d:head>
  <d:body xmlns:n="http://www.webui-ap.com/schemata/naming/1.0" n:cda-topic="topic">
    <xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">
      <d:if condition="foo"/>
    </xhtml:div>
    <d:select variable="foo">
      <d:repeat from="test"/>
    </d:select>
    <d:edit variable="foo"/>
  </d:body>
</d:document>

Desired view

<d:document xmlns:d="http://www.webui-ap.com/schemata/view/1.0"
            n:xmlns="http://www.webui-ap.com/schemata/naming/1.0"
            xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <d:head>
        <d:variable name="x" type="internal"/>
        <d:variable name="y" type="internal"/>
    </d:head>
    <d:body n:cda-topic="topic">
        <xhtml:div>
            <d:if condition="foo"/>
        </xhtml:div>
        <d:select variable="foo">
            <d:repeat from="test"/>
        </d:select>
        <d:edit variable="foo"/>
    </d:body>
</d:document>

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pdvriezecommented, Oct 16, 2022

Btw. if you want to put something in the default namespace you can use the empty string for both. You can also set a namespace for unprefixed elements by specifying the prefix to be the empty string. On prefixes, note that the library will try to reuse prefixes before using the ones specified.

0reactions
pdvriezecommented, Nov 7, 2022

I’ve fixed this (and #107 that was triggered upon solving the base problem). The problem was an infinite recursion in the descriptor tree that wasn’t considered possible (and thus not detected) - to collate namespace declarations the code walks the entire tree.

Read more comments on GitHub >

github_iconTop Results From Across the Web

W3C XML Schema Definition Language (XSD) 1.1 Part 1
This specification depends on XML Schema Definition Language 1.1 Part ... A document is root-valid against a given XSD schema if and only...
Read more >
Internal spec schema basics - IBM
The internal schema is an XSD document that is used at runtime to validate spec values, which are provided as an XML document...
Read more >
xml property and root schemas · Issue #1435 - GitHub
This is a question about the specification, and the intent of the following description in the Schema Object, relating to the xml property:...
Read more >
XML Schema: Understanding Namespaces - Oracle
It is not mandatory to declare namespaces only at the root element; ... attributes as defined in W3C XML Schema Structures Specification and...
Read more >
Schema Basics (XML in a Nutshell, 2nd Edition)
Assuming that the fullName element can only contain a simple string value, the schema ... Every schema document consists of a single root...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found