QuartzNet配置的SlowCheetah转换 [英] SlowCheetah transformations of QuartzNet config

查看:101
本文介绍了QuartzNet配置的SlowCheetah转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 SlowCheetah 设置QuartzNet作业配置文件的转换. QuartzNet要求xmlns属性必须存在于Job-scheduling-data节点上,但是该属性的存在似乎阻止了SlowCheetah运行转换.

I am trying to set up transformation, using SlowCheetah, of a QuartzNet job configuration file. QuartzNet requires the xmlns attribute to be present on the job-scheduling-data node, but the presence of this attribute seems to stop SlowCheetah from running the transformations.

简化,这是我的调度配置:

Simplified, this is what my scheduling config looks like:

<?xml version="1.0" encoding="UTF-8"?>
  <job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<schedule>
<job>
  <name>Job1</name>
  <group>Group1</group>
  <description>Description</description>
  <job-type>MySample.MyJob, MySample</job-type>
</job>

<trigger>
  <cron>
    <name>DefaultTrigger</name>
    <job-name>Job1</job-name>
    <job-group>Group1</job-group>
    <cron-expression>0 0 4 * * ? *</cron-expression>
    <time-zone>GMT Standard Time</time-zone>
  </cron>
</trigger>
</schedule>
</job-scheduling-data>

配置转换如下:

<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" >
<cron-expression xdt:Transform="Replace" xdt:Locator="XPath(/job-scheduling-data/schedule/trigger/cron/cron-expression[../name/text() = 'DefaultTrigger'])">"##DAILY_SCHEDULE##</cron-expression>
</job-scheduling-data>

除非我删除

xmlns="http://quartznet.sourceforge.net/JobSchedulingData" 

从原始配置文件和转换文件中输入

,或将名称空间指定为例如xmlns:ns1.这两种方法中的任何一种的问题在于Quartz都要求xmlns="http://quartznet.sourceforge.net/JobSchedulingData"出现.

from the original config file and the transformation file, or specify the namespace as, for example xmlns:ns1. The problem with either of these two approaches is that Quartz requires xmlns="http://quartznet.sourceforge.net/JobSchedulingData" to be present.

我还尝试将XPath表达式与local-name()一起使用,以忽略表达式语法中的名称空间,但无济于事.

I have also tried using XPath expressions with local-name() in an effort to ignore the namespace in the expression syntax, but to no avail.

有什么想法可以解决这个问题吗?

Any ideas how to get around this?

推荐答案

在我看来,您的XPath表达式应为:

It seems to me that your XPath expression should be:

/job-scheduling-data/schedule/trigger/cron/cron-expression[../job-name/text() = 'Job1']

因为它匹配name而不是job-name.

下面令人恐惧的忽略命名空间的XPath表达式也应该起作用:

The scary namespace-ignoring XPath expression below should also work:

/*[local-name()='job-scheduling-data']/*[local-name()='schedule']/*[local-name()='trigger']/*[local-name()='cron']/*[local-name()='cron-expression'][../*[local-name()='job-name']/text() = 'Job1']

这篇关于QuartzNet配置的SlowCheetah转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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