查找匹配项2个plist XML文件之间的元素不匹配? [英] Find matching & non matching elements between 2 plist XML files?

查看:97
本文介绍了查找匹配项2个plist XML文件之间的元素不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查找匹配项和整个文件中2个plist XML文件之间是否存在不匹配的元素?

Find matching & non matching elements between 2 plist XML files, throughout the files?

我有2个从iOS归档的.plist XML;仅供参考.

I have 2 .plist XML filed from iOS; just an FYI.

  • 重要的是弄清楚两个文件中都存在哪些项目(App),哪些不存在.

  • What matters is figuring out which of items (Apps) exist in both files, and which ones do not.

由于它们可以在XML结构的任何级别的任何位置以任何顺序存在于任何地方,因此无法使用Beyond Compare等进行简单的文件比较.

Since, they could exist in various places, in any order, at any level of the XML structure, a simple File Compare using Beyond Compare etc. would not work.

当XSLT 2.0工作时,我已经完成了很多XML/XSLT代码,而Saxon是唯一兼容的解析器.我在Win 8.1上有Altova XML Spy,DiffDog.

I've done quite a bit of XML/ XSLT code back when XSLT 2.0 was being worked and Saxon was the only compliant parser. I have Altova XML Spy, DiffDog on Win 8.1.

但是,如果更容易的话,我也愿意使用非XML/XSL机制来找出双方/双方都缺少什么,以及双方都有什么.

But, I'm open to figuring out what's missing on both sides/ each side and what's there in both, using a non XML/ XSL mechanism as well, if it's easier.

  • Item元素具有以下类型:<string>com.apple.MobileSMS</string>,并且可以存在于XML结构的各个位置.

  • Item Element is of this type: <string>com.apple.MobileSMS</string> and may exist at various places in the XML structure.

  • 存在于<array>下的 App 中,以进行匹配/比较计数
  • 可以存在文件夹名称,在<dict>下不计入匹配/比较
  • Exists as App under <array> to be counted for matching/ comparison
  • Can exist for Folder Names, under <dict> not to be counted for matching/ comparison

此处概述了有关此特定.plist XML结构的更多详细信息: http://iky1e.tumblr.com/post/11704062690/springboard- icon-layouts-iconstateplist

More details about this specific .plist XML structure is outlined here: http://iky1e.tumblr.com/post/11704062690/springboard-icon-layouts-iconstateplist

SpringBoard图标布局-IconState.plist

SpringBoard Icon Layouts - IconState.plist

我一直在寻找一种方法来获取所有未隐藏的应用程序的列表(因此,不包括Web.app之类的东西).
尽管我找到了它((NSArray *)[[SBIconModel sharedInstance] visibleIconIdentifiers]).我还发现SpringBoard保留了Icon布局的字典.

I was looking for a way to get a list of all applications, that aren’t hidden (so excluding things like Web.app).
And although I found it ((NSArray*)[[SBIconModel sharedInstance] visibleIconIdentifiers]). I also found a dictionary SpringBoard keeps of the Icon layout.

让我们仔细看看:

  • 基座图标在单独的数组中,用于键"buttonBar";
  • 页面位于键"iconLists"的数组中;
  • 每个页面都是iconLists数组中的一个单独数组;
  • 在每个页面的数组中,图标是字符串;
  • 图标字符串是应用的displayId;
  • 文件夹是NSDictionary;
  • 每个文件夹都有这些键;
    • 一个displayName键,它是一个字符串,它的名称;
    • iconLists,它是像每个页面一样的图标数组(displayId字符串);
  • the dock icons are in a separate array for key ‘buttonBar’;
  • the pages are in the array for key 'iconLists’;
  • each page is a separate array in the iconLists array;
  • in the array for each page the icons are string;
  • the icons string is the apps displayId;
  • a folder is an NSDictionary;
  • each folder has these keys;
    • a displayName key which is a string, it’s name;
    • iconLists which is an array of icons like each pages (displayId strings);
<!-- 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>

推荐答案

给出您的评论,听起来您需要一个列出所有唯一的string值的表,这些值是array元素的子代并且同时出现在两个文件中,还包括第一个文件的唯一值和第二个文件的唯一值的列表.

Given your comments, it sounds like you need a table listing all the unique string values that are children of array elements and that appear in both files, including also a list of values unique to the first file and those unique to the second file.

假设您已将两个文件加载到名为File1File2的变量中,则可以使用如下XPath表达式生成主完整列表:

Assuming you've loaded the two files into variables called File1 and File2, you could generate the main full list using an XPath expression like:

distinct-values($File1//array/string | $File2//array/string)

要测试File1唯一的值,其中上下文项.是主完整列表中的值之一:

To test for values unique to File1, where the context item . is one of the values in the main full list:

<xsl:if test=". = $File1//array/string and not(. = $File2//array/string)">

...以及对于File2唯一的值:

... and for values unique to File2:

<xsl:if test=". = $File2//array/string and not(. = $File1//array/string)">

可以进一步优化此方法,例如通过对列表进行排序.以上解决了您的核心需求.从那里,您可以决定如何布局值,无论是在HTML表中还是在其他结构中.

This approach could be further refined, such as by sorting the list. The above addresses the core of your needs. From there, you can decide how you want to lay out the values, be it in an HTML table or some other structure.

这篇关于查找匹配项2个plist XML文件之间的元素不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆