简体   繁体   English

与XSLT相比,XPath评估具有优势

[英]Advantage XPath Evaluation over XSLT

I'm currently programming an application, that uses WPF. 我当前正在编写一个使用WPF的应用程序。 Therefore I'm planning to load the GUI dynamically via XAML based upon a given XML. 因此,我计划基于给定的XML通过XAML动态加载GUI。

As I see it, I have two choices: 如我所见,我有两种选择:

  1. Evaluate XML by myself with xpath and create GUI elements by myself. 用xpath自己评估XML,并自己创建GUI元素。
  2. Generate XAML through a XSLT transformation and load that file. 通过XSLT转换生成XAML并加载该文件。

So, the question is, which way is more suitable? 那么,问题是,哪种方法更合适? Or is there no difference and it's just a question of which way I prefer more? 还是没有区别,这只是我更喜欢哪种方式的问题?

XSLT sounds like a bad choice: XSLT听起来是一个错误的选择:

  1. As soon as things get a bit harder, you start hacking around, plus .NET framework uses XSLT version which is older than the last one. 一旦事情变得有点困难,您就开始四处乱搞,.NET框架使用的XSLT版本比上一个版本旧。 Meaning; 含义; you have a lot less capabilities available, unless you start using third-party library for XSL transformations. 除非您开始使用第三方库进行XSL转换,否则可用的功能要少得多。
  2. Forcing developers to learn new technology which you can easily avoid. 迫使开发人员学习可以轻松避免的新技术。 Imagine new developer taking over of your work with no experience on XSLT. 想象一下,没有XSLT经验的新开发人员接管您的工作。 I imagine the code will be even hard to read for experienced developers. 我认为对于有经验的开发人员来说,这些代码甚至很难阅读。

With XML, it's pretty straight forward. 使用XML,这非常简单。 However, XPath can be also quite a mess, if you start nesting, and nesting. 但是,如果您开始嵌套和嵌套,那么XPath也会很混乱。

Define a XML format, use xml-->object deserialization, and start building UI from the objects. 定义XML格式,使用xml->对象反序列化,然后开始从对象构建UI。 Don't bother with Xpath . 不要理会Xpath Use XmlSerializer for "parsing". 使用XmlSerializer进行“解析”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM