【发布时间】:2017-05-02 05:28:50
【问题描述】:
在整个文件中查找 2 个 plist XML 文件之间的匹配和不匹配元素?
我有 2 个从 iOS 提交的 .plist XML;仅供参考。
重要的是弄清楚两个文件中存在哪些项目(应用程序),哪些不存在。
由于它们可以以任何顺序、在 XML 结构的任何级别存在于不同的位置,因此使用 Beyond Compare 等的简单文件比较将不起作用。
当 XSLT 2.0 工作时,我已经完成了相当多的 XML/XSLT 代码,而 Saxon 是唯一兼容的解析器。我在 Win 8.1 上有 Altova XML Spy、DiffDog。
但是,如果更容易的话,我也愿意使用非 XML/XSL 机制来弄清楚双方/每一方都缺少什么以及双方都缺少什么。
-
Item 元素属于这种类型:
<string>com.apple.MobileSMS</string>,并且可能存在于 XML 结构中的不同位置。- 作为应用程序存在于
<array>下以进行匹配/比较 -
文件夹名称可以存在,
<dict>下不计入匹配/比较
- 作为应用程序存在于
此处概述了有关此特定 .plist XML 结构的更多详细信息: http://iky1e.tumblr.com/post/11704062690/springboard-icon-layouts-iconstateplist
SpringBoard 图标布局 - IconState.plist我一直在寻找一种方法来获取所有应用程序的列表,这些应用程序不是隐藏的(因此不包括 Web.app 之类的东西)。
尽管我找到了它((NSArray*)[[SBIconModel sharedInstance] visibleIconIdentifiers])。我还找到了一本 SpringBoard 保留的图标布局的字典。让我们仔细看看:
- 停靠图标位于键“buttonBar”的单独数组中;
- 页面位于键“iconLists”的数组中;
- 每一页都是iconLists数组中的一个单独数组;
- 在每个页面的数组中,图标都是字符串;
- icons 字符串是应用的 displayId;
- 文件夹是 NSDictionary;
- 每个文件夹都有这些键;
- 一个 displayName 键,它是一个字符串,它的名字;
- iconLists 是一个像每个页面一样的图标数组(displayId 字符串);
<!-- language-all: lang-xml -->
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<all>
<!-- Outer <dict> replaced by <all> -->
<key>buttonBar</key>
<array>
<string>com.apple.MobileSMS</string>
<string>com.apple.mobilemail</string>
<string>com.apple.mobilesafari</string>
</array>
<key>iconLists</key>
<pages>
<!-- replaced by <pages> -->
<page>
<!-- replaced by <page> -->
<string>com.apple.mobilephone</string>
<string>com.apple.mobilecal</string>
<string>com.apple.mobileslideshow</string>
<string>com.apple.camera</string>
<string>com.apple.videos</string>
<string>com.apple.youtube</string>
<string>com.apple.Maps</string>
<string>com.apple.weather</string>
<string>com.apple.mobilenotes</string>
<string>com.apple.reminders</string>
<string>com.apple.mobiletimer</string>
<string>com.apple.gamecenter</string>
<dict>
<!-- Inner <dict> represents Folders -->
<key>displayName</key>
<string>Apple</string>
<key>iconLists</key>
<array>
<array>
<string>com.apple.mobileme.fmf1</string>
<string>com.apple.Cards</string>
<string>com.apple.iBooks</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<string>com.apple.MobileStore</string>
<string>com.apple.AppStore</string>
<string>com.apple.Preferences</string>
</page>
<page>
<dict>
<key>displayName</key>
<string>Utilities</string>
<key>iconLists</key>
<array>
<array>
<string>com.apple.MobileAddressBook</string>
<string>com.apple.calculator</string>
<string>com.apple.VoiceMemos</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<dict>
<key>displayName</key>
<string>Jailbreak</string>
<key>iconLists</key>
<array>
<array>
<string>com.saurik.Cydia</string>
<string>libactivator</string>
<string>eu.heinelt.ifile</string>
<string>crash-reporter</string>
<string>com.googlecode.mobileterminal.Terminal</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<dict>
<key>displayName</key>
<string>Social</string>
<key>iconLists</key>
<array>
<array>
<string>com.atebits.Tweetie2</string>
<string>info.colloquy.mobile</string>
<string>com.tapbots.Tweetbot</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<dict>
<key>displayName</key>
<string>Other</string>
<key>iconLists</key>
<array>
<array>
<string>com.apple.stocks</string>
<dict>
<key>displayName</key>
<string>Newsstand</string>
<key>iconLists</key>
<array/>
<key>listType</key>
<string>newsstand</string>
</dict>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<string>com.clickgamer.AngryBirds</string>
<string>com.apple.mobileipod</string>
</page>
<page>
<dict>
<key>displayName</key>
<string>Utilities</string>
<key>iconLists</key>
<array>
<array>
<string>com.apple.MobileAddressBook</string>
<string>com.apple.calculator</string>
<string>com.apple.VoiceMemos</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<dict>
<key>displayName</key>
<string>Jailbreak</string>
<key>iconLists</key>
<array>
<array>
<string>com.saurik.Cydia</string>
<string>libactivator</string>
<string>eu.heinelt.ifile</string>
<string>crash-reporter</string>
<string>com.googlecode.mobileterminal.Terminal</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<dict>
<key>displayName</key>
<string>Social</string>
<key>iconLists</key>
<array>
<array>
<string>com.atebits.Tweetie2</string>
<string>info.colloquy.mobile</string>
<string>com.tapbots.Tweetbot</string>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<dict>
<key>displayName</key>
<string>Other</string>
<key>iconLists</key>
<array>
<array>
<string>com.apple.stocks</string>
<dict>
<key>displayName</key>
<string>Newsstand</string>
<key>iconLists</key>
<array/>
<key>listType</key>
<string>newsstand</string>
</dict>
</array>
</array>
<key>listType</key>
<string>folder</string>
</dict>
<string>com.clickgamer.AngryBirds</string>
<string>com.apple.mobileipod</string>
</page>
</pages>
</all>
</plist>
【问题讨论】:
-
为了重申基本问题,您希望获得两个输入文件中都存在的
array/string值列表?或者您是否还需要仅存在于两个输入文件之一中的array/string值列表? -
另外,请发布您尝试过的内容,并说明哪些有效,哪些无效。
-
@EiríkrÚtlendi - 我想要一个列表,列出常见的内容、仅在左侧文件中的内容以及仅在右侧文件中的内容。最好采用易于阅读的表格格式
-
@EiríkrÚtlendi - 到目前为止我所尝试的,在 10 多年后使用 XSL,所以逐步进行 - 完成了一些基础知识 - stackoverflow.com/questions/43761829/…