如何让 FlashBuilder 使用自定义命名空间前缀

发布于 2024-11-16 23:17:38 字数 1452 浏览 3 评论 0原文

我有一个组件库。它有一个如下所示的清单文件:

<?xml version="1.0"?>
<componentPackage>
    <component id="AutoComplete" class="be.edge.components.AutoComplete" />
    <!-- more components left out for brevity -->
</componentPackage>

我使用以下编译器设置通过 FlashBuilder 编译该库:

FlashBuilder 库编译器命名空间输入

当我在其他 FlashBuilder 项目中使用编译后的库时,一切都按预期工作。我获得了代码完成,当我从代码完成中选择建议时,名称空间属性会自动添加到组件中,如下所示:

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:ns="library://ns.edge.be" >

    <ns:AutoComplete />

</s:Skin>

但是: FlashBuilder 会自动创建前缀“ns”。例如,我想将其自定义为“e”。如何让 FlashBuilder 默认使用此自定义前缀?

我这样做有两个原因:

  1. “ns”没有说什么:它只是说命名空间已被使用,而不是什么命名空间。
  2. 当我使用其他也以“library://ns”等 url 开头的库时。 FlashBuilder 可能会开始对前缀进行编号来解决冲突(ns、ns1、ns2 等),这会更加令人困惑。

编辑:

我还将 config.xml 传递给编译器,其中包含以下与命名空间相关的声明:

<compiler>
    <namespaces>
        <namespace>
            <uri>library://ns.edge.be</uri>
            <manifest>manifest.xml</manifest>
        </namespace>
    </namespaces>
</compiler>

<include-namespaces>
    <uri>library://ns.edge.be</uri>
</include-namespaces>

I have a component library. It has a manifest file that looks like this:

<?xml version="1.0"?>
<componentPackage>
    <component id="AutoComplete" class="be.edge.components.AutoComplete" />
    <!-- more components left out for brevity -->
</componentPackage>

I compile the library through FlashBuilder with these compiler settings:

FlashBuilder library compiler namespace inputs

When I use the compiled library in other FlashBuilder projects everything works as expected. I get code completion and when I select a suggestion from the code completion a namespace attribute is automatically added to the component, like this:

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:ns="library://ns.edge.be" >

    <ns:AutoComplete />

</s:Skin>

But: FlashBuilder automatically creates the prefix 'ns'. I would like to customize this to 'e' for instance. How can I make FlashBuilder use this custom prefix by default?

I have two reasons for this:

  1. 'ns' doesn't say anything: it just says A namespace has been used, not what namespace.
  2. when I use other libraries that also start with a url like 'library://ns.' FlashBuilder will probably start numbering the prefixes to resolve the conflict (ns, ns1, ns2, etc.), which would be even more confusing.

EDIT:

I also pass a config.xml to the compiler that has the following declarations relating to namespaces:

<compiler>
    <namespaces>
        <namespace>
            <uri>library://ns.edge.be</uri>
            <manifest>manifest.xml</manifest>
        </namespace>
    </namespaces>
</compiler>

<include-namespaces>
    <uri>library://ns.edge.be</uri>
</include-namespaces>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神仙妹妹 2024-11-23 23:17:38

用于工作:

在 /src 文件夹中创建一个名为 design.xml 的文件:

<?xml version="1.0" ?>
<design>
    <namespaces>
        <namespace prefix="mangos" uri="http://com.mangofactory.sample/mxml/2010" />
    </namespaces>
</design>

在 /src 中创建一个名为 manifest.xml 的文件文件夹:

<componentPackage>
        <component id="MyClass" class="com.mangofactory.framework.MyClassTag"/>
</componentPackage>

在构建属性中配置您的命名空间 URL 等:
在此处输入图像描述

应该会导致 flash builder 提示如下:(

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:mangos="http://com.mangofactory.sample/mxml/2010">
    <fx:Declarations>
        <mangos:MyClass />
    </fx:Declarations>
</s:Application>

请注意该类显示为 MyClass 而不是 MyClassTag,命名空间显示为 mangos

但是,我只是尝试这样做,尽管该类是正确重命名,命名空间显示为ns。我知道这曾经在 FB3.x 中工作,也许我忘记了一个步骤,或者 FB4.5 破坏了它。

This used to work:

Create a file called design.xml in your /src folder:

<?xml version="1.0" ?>
<design>
    <namespaces>
        <namespace prefix="mangos" uri="http://com.mangofactory.sample/mxml/2010" />
    </namespaces>
</design>

Create a file called manifest.xml in your /src folder:

<componentPackage>
        <component id="MyClass" class="com.mangofactory.framework.MyClassTag"/>
</componentPackage>

Configure your Namespace URL, etc in the build properties:
enter image description here

This is supposed to cause flash builder to prompt as follows:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:mangos="http://com.mangofactory.sample/mxml/2010">
    <fx:Declarations>
        <mangos:MyClass />
    </fx:Declarations>
</s:Application>

(Note that the class appears as MyClass instead of MyClassTag, and the namespace appears as mangos)

However, I just tried doing this, and although the class was renamed correctly, the namespace appeared up as ns. I know this used to work in FB3.x, maybe I've either forgotten a step, or FB4.5 has broken it.

吲‖鸣 2024-11-23 23:17:38

如果您只是将 xmlns:ns 更改为 xmlns:exmlns:foo,则 MXML 解析器将接受更改。更改并不是那么困难,而且我认为没有办法更改它默认生成名称空间的方式。

If you just change xmlns:ns to xmlns:e or xmlns:foo then the MXML parser will pick up on the change. It's not all that difficult to change, and I don't think there is a way to change how it generates namespaces by default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文