Page 1 of 1

Namespace definitions as code templates

Posted: Wed Oct 11, 2017 8:54 pm
by dcramer
I'm a big fan of code templates and of course we all love namespaces. I notice that there's already a code template for the xsl namespace that's limited to the xslt editor. That's cool, but...

Feature request #1: It should really be possible to define a code template as being for all xml editors (xml, xslt, xproc, schematron, etc). I'm unlikely to need an code template for xmlns:xsl in the xslt editor since I probably created the xslt from a document template which defines that on the root element. I AM likely to need to insert an xsl namespace definition in an xproc pipeline or schematron.

Feature request #2: Add out-of-the-box code templates for all the common namespaces. I would suggest making the renderString for all of them start with the same letters so that they'll be grouped together in the list and won't clutter things up as much:

xnssvg => xmlns:svg="http://www.w3.org/2000/svg"
xnsxproc => xmlns:p="http://www.w3.org/ns/xproc"
xnsxprocstep => xmlns:c="http://www.w3.org/ns/xproc-step"
xnsfo => xmlns:fo="http://www.w3.org/1999/XSL/Format"
xnsxi => xmlns:xi="http://www.w3.org/2001/XInclude"
xnsxs => xmlns:xs="http://www.w3.org/2001/XMLSchema"
xnsdb => xmlns:db="http://docbook.org/ns/docbook"
and so on.

I defined two, nsdb and nsdbd, one to define xmlns:db and the other to insert xmlns="http://docbook.org/ns/docbook" for when I want to use it as the default namespace:

Code: Select all


			<codeTemplateItem-array>
<codeTemplateItem>
<field name="contentType">
<String>text/any</String>
</field>
<field name="unparsedInsertString">
<String>xmlns="http://docbook.org/ns/docbook"${caret}</String>
</field>
<field name="descriptionString">
<String>Make DocBook the default namespace</String>
</field>
<field name="renderString">
<String>xnsdbd</String>
</field>
<field name="enabled">
<Boolean>true</Boolean>
</field>
<field name="accelerator">
<null/>
</field>
</codeTemplateItem>
<codeTemplateItem>
<field name="contentType">
<String>text/any</String>
</field>
<field name="unparsedInsertString">
<String>xmlns:db="http://docbook.org/ns/docbook"${caret}</String>
</field>
<field name="descriptionString">
<String>Define DocBook namespace as db:</String>
</field>
<field name="renderString">
<String>xnsdb</String>
</field>
<field name="enabled">
<Boolean>true</Boolean>
</field>
<field name="accelerator">
<null/>
</field>
</codeTemplateItem>

Re: Namespace definitions as code templates

Posted: Thu Oct 12, 2017 5:03 pm
by adrian
Hello,
#1: It should really be possible to define a code template as being for all xml editors (xml, xslt, xproc, schematron, etc). I'm unlikely to need an code template for xmlns:xsl in the xslt editor since I probably created the xslt from a document template which defines that on the root element. I AM likely to need to insert an xsl namespace definition in an xproc pipeline or schematron.
Note that it's currently possible to make a code template available for "All Editors" (first item in the list of "Associate with"). Currently, there are no other groups of editors, but we could accommodate some. I've logged a feature request.
#2: Add out-of-the-box code templates for all the common namespaces. I would suggest making the renderString for all of them start with the same letters so that they'll be grouped together in the list and won't clutter things up as much:
I've logged a feature request for this.

Regards,
Adrian

Re: Namespace definitions as code templates

Posted: Thu Oct 12, 2017 8:02 pm
by dcramer
It would be really cool if I could associate the code templates with namespaces, so if I'm in the xslt namespace, not matter what kind of document, I can use the xslt-related code templates.

So if I'm editing an xproc file, I could use a code template to enter the following, and once I'm at ${caret}, I now have available all the usual xslt-related code templates:

Code: Select all


            <p:inline>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://docbook.org/ns/docbook"
exclude-result-prefixes="xhtml" version="2.0">
${caret}
</xsl:stylesheet>
</p:inline>