namespace dependent format and indent
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 37
- Joined: Mon Jan 23, 2017 11:20 am
namespace dependent format and indent
Hi oXygen team,
I want to configure my Editor to format and indent elements with the same name but from different namespaces differently. E.g. ns1:element should stay inline while ns2:element should have line-breaks before and after. Nevertheless I do not manage to properly configure this in Preferences/Editor/Format/XML.
I did set "ns2:element" in the line-break tab but it seems that the namespace-prefix is not being resolved. It works if I only enter "element" but then it would also affect ns1:element.
What am I doing wrong?
Thanks for helping!
I want to configure my Editor to format and indent elements with the same name but from different namespaces differently. E.g. ns1:element should stay inline while ns2:element should have line-breaks before and after. Nevertheless I do not manage to properly configure this in Preferences/Editor/Format/XML.
I did set "ns2:element" in the line-break tab but it seems that the namespace-prefix is not being resolved. It works if I only enter "element" but then it would also affect ns1:element.
What am I doing wrong?
Thanks for helping!
=====
oXygen XML Editor v24.1
macOS Monterey 12.3.1 Apple Silicon
oXygen XML Editor v24.1
macOS Monterey 12.3.1 Apple Silicon
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: namespace dependent format and indent
Hi,
What version of Oxygen are you using?
Could you provide a complete (but small) example XML file where you see the issue? It could be something that happens in a specific context.
Do note that Oxygen will already insert some line breaks by default (e.g. in element only blocks). So it's usually more difficult to configure it not to enter line breaks.
Regards,
Adrian
What version of Oxygen are you using?
I cannot reproduce this issue in v19.1. For me it doesn't work at all with "element", only with ns2:element.I did set "ns2:element" in the line-break tab but it seems that the namespace-prefix is not being resolved. It works if I only enter "element" but then it would also affect ns1:element.
Could you provide a complete (but small) example XML file where you see the issue? It could be something that happens in a specific context.
Do note that Oxygen will already insert some line breaks by default (e.g. in element only blocks). So it's usually more difficult to configure it not to enter line breaks.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 37
- Joined: Mon Jan 23, 2017 11:20 am
Re: namespace dependent format and indent
Dear Adrian,
thanks for the reply and sorry for replying late…
I am using oxygen 18.1 on OSX Sierra (see signature
To give an example:
Let's say we have to namespaces (as I have them configured them in the XPath default namespaces):
mei:xmlns="http://www.music-encoding.org/ns/mei"
tei:xmlns="http://www.tei-c.org/ns/1.0"
To make up an example (N.B. for anyone reading this: this is not cannon TEI or MEI, just a made up example)
Let's say they both define n element <lb/> indicating a line-break in a text and while TEI would define this as marking the start of a new line, MEI would define it as marking the end of a line. So I would configure in "Editor/Format/XML/" Line break Tab:
tei:lb with selected Before
mei:lb with selected After
unfortunately doesn't work out…
the format and indent ignores the configuration, obviously due to the fact that it does not recognise the namespaces elements. With a general rule for "lb" it works though…
Here's the TEI example:
and the MEI example:
thanks for the reply and sorry for replying late…
I am using oxygen 18.1 on OSX Sierra (see signature

To give an example:
Let's say we have to namespaces (as I have them configured them in the XPath default namespaces):
mei:xmlns="http://www.music-encoding.org/ns/mei"
tei:xmlns="http://www.tei-c.org/ns/1.0"
To make up an example (N.B. for anyone reading this: this is not cannon TEI or MEI, just a made up example)
Let's say they both define n element <lb/> indicating a line-break in a text and while TEI would define this as marking the start of a new line, MEI would define it as marking the end of a line. So I would configure in "Editor/Format/XML/" Line break Tab:
tei:lb with selected Before
mei:lb with selected After
unfortunately doesn't work out…
the format and indent ignores the configuration, obviously due to the fact that it does not recognise the namespaces elements. With a general rule for "lb" it works though…
Here's the TEI example:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>Title</title>
</titleStmt>
<publicationStmt>
<p>Publication Information</p>
</publicationStmt>
<sourceDesc>
<p>Information about the source</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<body>
<p>Some text here.<lb/>yet some more.</p>
</body>
</text>
</TEI>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
<meiHead>
<fileDesc>
<titleStmt>
<title/>
</titleStmt>
<pubStmt/>
</fileDesc>
</meiHead>
<music>
<body>
<div>
<p>Some text here.<lb/>yet some more.</p>
</div>
<mdiv>
</mdiv>
</body>
</music>
</mei>
=====
oXygen XML Editor v24.1
macOS Monterey 12.3.1 Apple Silicon
oXygen XML Editor v24.1
macOS Monterey 12.3.1 Apple Silicon
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: namespace dependent format and indent
Hello,
I see the problem now. The thing is the XML formatting options aren't actually namespace aware (namespace prefixes don't get resolved), they are only namespace prefix-aware.
Another thing to add is that only simple XPath expressions can be used in the formatting options:
To clarify, for your particular situation (default namespace on the root and same local name for element), you cannot configure the Oxygen formatter to distinguish between the two 'lb' elements from different namespaces.
Regards,
Adrian
I see the problem now. The thing is the XML formatting options aren't actually namespace aware (namespace prefixes don't get resolved), they are only namespace prefix-aware.
The "Default prefix-namespace mappings" declared in Preferences > XML / XSLT-FO-XQuery / XPath only apply to the XPath tools (XPath toolbar and XPath/XQuery Builder). These namespace mappings do not apply to the formatting options, so mei:lb and tei:lb have no effect there, as the prefixes mei and tei are never resolved.bwbohl wrote:Let's say we have to namespaces (as I have them configured them in the XPath default namespaces):
mei:xmlns="http://www.music-encoding.org/ns/mei"
tei:xmlns="http://www.tei-c.org/ns/1.0"
Another thing to add is that only simple XPath expressions can be used in the formatting options:
This means you cannot actually specify the namespace for the formatter, just the namespace prefix, as part of the element name.//xs:localName Note: The namespace prefixes (such as xs) are treated as part of the element name without taking its binding to a namespace into account.
To clarify, for your particular situation (default namespace on the root and same local name for element), you cannot configure the Oxygen formatter to distinguish between the two 'lb' elements from different namespaces.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 37
- Joined: Mon Jan 23, 2017 11:20 am
Re: namespace dependent format and indent
If I get you right it would not be possible to enter something like:
because it does supersede the implemented simplified XPath.
If I'd consequently use prefixes in my XML-files, though, as in this modified example from above:
it works!
Thanks, very valuable tip!
Nevertheless I'd opt for a section in the preferences where one can define application-wide (global or project specific) namespace prefixes. You may consider this a feature request
Code: Select all
lb[namespace-uri()='http://www.tei-c.org/ns/1.0 ']
If I'd consequently use prefixes in my XML-files, though, as in this modified example from above:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<tei:TEI xmlns:tei="http://www.tei-c.org/ns/1.0">
<tei:teiHeader>
<tei:fileDesc>
<tei:titleStmt>
<tei:title>Title</tei:title>
</tei:titleStmt>
<tei:publicationStmt>
<tei:p>Publication Information</tei:p>
</tei:publicationStmt>
<tei:sourceDesc>
<tei:p>Information about the source</tei:p>
</tei:sourceDesc>
</tei:fileDesc>
</tei:teiHeader>
<tei:text>
<tei:body>
<tei:p>Some text here.
<tei:lb/>yet some more.</tei:p>
</tei:body>
</tei:text>
</tei:TEI>
Thanks, very valuable tip!
Nevertheless I'd opt for a section in the preferences where one can define application-wide (global or project specific) namespace prefixes. You may consider this a feature request

=====
oXygen XML Editor v24.1
macOS Monterey 12.3.1 Apple Silicon
oXygen XML Editor v24.1
macOS Monterey 12.3.1 Apple Silicon
Return to “SDK-API, Frameworks - Document Types”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service