alunny / cordova-plugin-spec

experimental specification for Cordova plugins
43 stars 12 forks source link

<config-file> should have text as innerxml rather than actual xml #4

Open Zammy opened 12 years ago

Zammy commented 12 years ago

I believe should have their contents as literal strings. Technically we do not care what kind of xml is inside. We just want to insert this text at the end of XPath element inner xml. Actually parsing is pretty difficult (at least in .NET). When you read it namespaces are added to xml inside which is not what we want but what should happened to have self contained xml.

Here is how I changed the plugin.xml for AndroidManifest of Child Browser.

    <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <![CDATA[ <activity android:name="com.phonegap.plugins.childBrowser.ChildBrowser"
                  android:label="@string/app_name">
            <intent-filter>
            </intent-filter>
        </activity> ]]>
    </config-file>
alunny commented 12 years ago

How are the inner tags being transformed by the .NET parser?

Zammy commented 12 years ago

It takes the phonegap namespace and put it in as global namespace. That is by some XML language standard I assume.

Because and are not in any namespace, the parser takes the global one, which is phonegap and puts it in every xml tag. This way you have self-contained XML with the namespace. It is syntatically correct with your XML but it is wrong for our case because xml is actually in android namespace. When you put the inside without specifing which namespace it is, it becomes part of the global one, which is phonegap.

We should either use literal string for the content, as we do not care for the XML inside but for its content, or specificy the namespace for all level 1 tags inside aka . I am not 100% the second solution will work but the first one works perfectly.

/offtopic: Why not JSON? What does xml give us ?