我正在为我的客户开发一个应用程序.我们在strings.xml中创建的内容是专有的,他们需要在
XML文件中发布版权声明及其商标声明.
我希望能够列出我的版权和我客户的版权.
将这些信息包含在xml中的做法是什么?我是否创建了一个名为“copyright”的标签?
解决方法
XML不是由公众查看,而是由开发人员或工具查看.
携带作者信息是数据的一部分(如在有作者的博客文章中),或者不是.
但是,您可以使用XML注释.或者您可以定义自己的XSD并构建如下所示的所有内容:
<?xml?> <!-- copyright notices here From you regarding the XML itself From your client regarding the XML contents --> <root xmlns:copyright="http://www.w3.org/1999/xhtml"> <!-- per file Meta-data here --> <Metadata> <!-- authors make it --> <author name="XXXXX" /> <!-- copyright holders buy it from authors and sell it --> <copyright name="XXXXX" /> <license type="GPL"> Lorem ipsum dolor sit amet... </license> </Metadata> <data> <entry> <!-- per entry Meta-data here --> <Metadata> <author name="XXXXX" /> </Metadata> <contents> </contents> </entry> </data> </root>
此外,如果第三方应用程序(要提取和显示)需要它,如果您使用XML元素而不是注释,则会更有用,因为它们易于操作.
我的意思是可以用简单的文本进行评论,但如果你想在我的例子中展示复杂的信息,就像作者/版权/许可证这样的子字段,第三方程序员很容易得到那些节点对象.
作为一种变体,如果你感觉特别僵化:
<?xml?> <!-- copyright notices here From you regarding the XML itself From your client regarding the XML contents --> <root xmlns:copyright="http://www.w3.org/1999/xhtml"> <!-- per file Meta-data here --> <copyright:info> <!-- authors make it --> <copyright:author name="XXXXX" /> <!-- copyright holders buy it from authors and sell it --> <copyright:holder name="XXXXX" /> <copyright:license type="GPL"> Lorem ipsum dolor sit amet... </copyright:license> </copyright:info> <data> <entry copyright:author="author name" copyright:holder="holder name"> <contents> </contents> </entry> </data> </root>
使用命名空间,第三方程序员可以轻松地分离两层信息.