Extract XML namespace declarations into separate t

2019-02-25 18:01发布

I would like to seperate my XML namespace declarations at the top of the page into a seperate (tag)file in which I can include in any Facelets page I wish.

Is this possible? Or do I need to copypaste all XML namespaces in each Facelets file?

Here's a theoretical example, xmlns.xhtml:

<something
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    ...
/>

And the template file which could use it: mypage.xhtml:

<f:view xmlns="xmlns.xhtml">
    <h:head>
        ...
    </h:head>
    <h:body>
        ...
    </h:body>
</f:view>

1条回答
【Aperson】
2楼-- · 2019-02-25 18:30

Nope, not possible. They must be present during XML compile time already.

Your best bet is creating or configuring XHTML template(s) in your IDE so that you can choose from them in New File without the need to copypaste/retype the boilerplate.

Here are some screens from Eclipse + JBoss Tools:

enter image description here

enter image description here

enter image description here

查看更多
登录 后发表回答