test-runner 相关问题


XCode 15 没有这样的模块'__ObjC'

当我运行 pod install 时,这些磨损就会出现。 [!] Runner [Debug] 目标会覆盖 Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig 中定义的 ENABLE_BITCODE 构建设置。这……


自托管的 GitHub Actions Runner 可以在托管 GitHub Runner 的同一台计算机上部署应用程序吗?

我目前正在尝试使用在 Ubuntu VM 上运行的自托管 GitHub Actions Runner 来配置启用了 GitHub Actions 的 GitHub 存储库。 我想将我的应用程序部署到...


使用 Karate Runner 和 Gradle Kotlin 调试空手道

由于 Gradle 默认其构建文件使用 Kotlin,而且我从来都不是 Groovy 的粉丝,因此尝试使用开源 Karate Runner (v1.2.5) 进行调试。我已经尝试了几个版本...


InvalidStateError:无法在“CanvasRenderingContext2D”上执行“drawImage”:提供的 HTMLImageElement 处于“损坏”状态

从 'matter-js' 导入 { Bodies, Composite, Engine, Mouse, MouseConstraint, Render, Runner }; 从 'react' 导入 React, { useEffect }; 从 './styles' 导入 * as S; 从“../../.....”导入颤振


如何使用 .NET TEST EXPLORER 在 VS Code 中运行 NUnit 测试

我想从 .NET TEST EXPLORER 运行单元测试,而不是命令行。我可以在导航到单元测试目录并执行 dotnet test 时运行测试。 但选择 .NET TEST EXPLORER...


proxmox 的 github 操作出现 Terraform 计划错误

我尝试使用 Proxmox 进行 Terraform,效果很好。尝试通过自托管 github runner 来学习和利用 GitHub 操作功能 名称:LCX_2 在: 工作流程_调度: 环境: PM_API_URL:${{


闪亮的server.R无法读取全局变量

./app 中的两个文件 ui.R 图书馆(闪亮) 一个<- 1 ui <- fluidPage( textOutput("test") ) server.R server <- function(input, output) { output$test <- renderText({ a ...


php 使用函数更改函数外部变量的值

我试图在使用函数时更改函数外部声明的变量的值 我试图更改在使用函数时声明的变量的值 <?php $test = 1; function addtest() { $test = $test + 1; } addtest(); echo $test; ?> 但似乎不能。只有在函数中声明为参数的变量才有效。有这方面的技术吗?预先感谢 将函数内部的变量更改为全局变量 - function addtest() { global $test; $test = $test + 1; } 使用全局变量有很多注意事项 - 从长远来看,您的代码将更难维护,因为全局变量可能会对未来的计算产生不良影响,您可能不知道如何操纵变量。 如果重构代码并且函数消失,这将是有害的,因为 $test 的每个实例都与代码紧密耦合。 这里有一个轻微的改进,不需要 global - $test = 1; function addtest($variable) { $newValue = $variable + 1; return $newValue; } echo $test; // 1 $foo = addtest($test); echo $foo; // 2 现在您不必使用全局变量,并且可以根据自己的喜好操作 $test,同时将新值分配给另一个变量。 不确定这是否是一个人为的示例,但在这种情况下(与大多数情况一样),使用global将是极其糟糕的形式。为什么不直接返回结果并分配返回值呢? $test = 1; function increment($val) { return $val + 1; } $test = increment($test); echo $test; 这样,如果您需要增加除 $test 之外的 任何其他 变量,您就已经完成了。 如果您需要更改多个值并返回它们,您可以返回一个数组并使用 PHP 的 list 轻松提取内容: function incrementMany($val1, $val2) { return array( $val1 + 1, $val2 + 1); } $test1 = 1; $test2 = 2; list($test1, $test2) = incrementMany($test1, $test2); echo $test1 . ', ' . $test2; 您还可以使用 func_get_args 接受动态数量的参数并返回动态数量的结果。 使用 global 关键字。 <?php $test = 1; function addtest() { global $test; $test = $test + 1; } addtest(); echo $test; // 2 ?> 也许你可以试试这个。 <?php function addTest(&$val){ # Add this & and val will update var who call in from outside $val += 1 ; } $test = 1; addTest($test); echo $test; // 2 $anyVar = 5; addTest($anyVar); echo $anyVar; // 6


replit 无法安装/使用discord.opus

问候。 我从两年前就有了一个不和谐的音乐机器人,当时它工作得很好。但现在当我尝试播放某些东西时,我收到以下错误: 文件“/home/runner/Goorbebot...


指定psql连接的默认数据库?

在使用psql时,我想更改初始数据库连接。 我有一个名为“test”的数据库作为初始连接。 从命令行运行 psql 时,我的提示符为 test=# 之后


写入通道的随机结果(Go)

我有以下代码: 函数 writeToClosedBufferedChannel() { ch := make(chan int, 2) ch <- 10 ch <- 20 go func() { fmt.Println("test") ch <- ...


使用Pytest时将主数据库更改为Test

帮我解决问题 这是我的设置.py: 数据库= { “默认”: { "ENGINE": "django.db.backends.mysql", “名称”:ENV.MYSQL_DSN....


来自有序字典的Python Json

我正在尝试创建一个嵌套的 Json 结构,如下所示: 示例 Json: { “id”:“德”, “密钥”:“1234567”, “来自”:“[email protected]”, “过期”:“2018-04-2...


如何使用xslt将xml中的文本转换为html中的超链接

如何使用 xslt 将 xml 中的文本转换为 html 中的超链接。 我的 Xml 代码是 C:\测试\CaptureF15165617TC001_05_06_1516_57_11.png 如何使用 xslt 将 xml 中的文本转换为 html 中的超链接。 我的Xml代码是 <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps> 将其转换为 html,我的 xslt 代码如下 <td width='15%'> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> </xsl:element> </td> 现在这段代码在html中写入文件的整个路径,但我只想在html中写入“文件”以及指向文件位置的超链接。 我当前生成的html代码如下 C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png <td width="15%"><a href="C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png">C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</a></td> 我想要的是 <td width="15%"><a href="C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png">File</a></td> 任何人都可以帮助我需要在 xslt 中进行哪些更改。 你告诉它具有价值: <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> <!--This is the link text --> </xsl:element> 所以将其更改为: <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> File </xsl:element> 或者简短地说: <a href="{Filepath}">File</a> <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps>


mod_rewrite到子目录中相应的php文件

我想使用 mod_rewrite (在 .htaccess 中)将“干净”的 URL 映射到子目录中相应的 php 文件,例如: https://example.com/test/ --> https://example.com/p/test.php 我的...


AWS sts 在一个命令中承担角色

要在 CLI 中承担 AWS 角色,我执行以下命令: aws sts 假设角色 --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test --region eu-central-1 这给...


ASP Fix/Int 函数未按预期运行

在调试时,我在自定义 RoundMid() 函数中发现了这个奇怪的事情: 测试 = 148.325 * 100 + 0.5 Response.Write 测试 ' 返回 14833 Response.Write Fix(test) ' 返回 14832 ??????...


如何从.Net Core中的Content.ReadAsStringAsync方法获取字符串?

我正在尝试读取 WEB API 的响应,该响应返回字符串。 我使用下面的语句: response.Conent.ReadAsStringAsync().Result.ToString(); 我期待结果是“TEST”...


为什么将迭代器 '(vector<int> a).begin()' 传递给参数 'vector<T>::iterator b' 时无法推断 'T' 的类型?

有以下代码: 模板 void test(const typename std::vector::iterator &i){ } int main(int argc, char **argv) { std::向量 a; 测试(a.


MySQL 事件——执行需要 EVENT 权限吗?

MySQL 5.7 (Win) 和 MariaDB 10.1 (Linux),事件计划程序设置为 ON,我以 root 身份连接。 创建数据库“事件测试”; 创建用户“event-test”@“localhost”,由“password-is-here”标识; 格...


xcodebuild 在使用 test-without-building 时忽略 testPlan

考虑这个示例项目:https://github.com/stremsdoerfer/TestPlan。这只是一个 Hello World,它有两个测试计划:仅运行单元测试的 TestPlanUnit 和仅运行 UI 测试的 TestPlanUI...


如何在spring-boot web客户端发送请求体?

我在 Spring Boot Web 客户端发送请求正文时遇到一些问题。尝试发送如下所示的正文: val 主体 = "{ ” + "\"电子邮件\":\"[email protected]\", ” + “\”id\“:...


如何在 RTL 测试中使用 React Redux useDispatch 钩子?

我想在使用 redux 调度后测试 React 组件。我正在使用“test-utils.ts”文件中的自定义渲染函数: 从 'react' 导入 { ReactElement } 导入{渲染,渲染O...


Hyperledger Fabric 测试网络:$ sudo ./network.sh up(不起作用)

我是超级账本结构的新手,在设置测试网络时遇到错误。 我从 docker-compose github 存储库下载了 Fabric-samples。 然后将目录更改为 test-network。 不...


无法从S3存储桶下载文件。 (Langchain + s3)

我正在编写一个项目,使用s3来存储文件pdf,并使用langchain来连接和加载文件。 这是我的代码: const loader = new S3Loader({ bucket: process.env.BUCKET, key: filekey, // 示例: test/


尝试部署我的 Aave 闪贷测试但出现错误。 https://github.com/aave/flashloan-box

每当我运行“truffle test”时,我都会收到以下错误: 错误:助记符无效或未定义 在 checkBIP39Mnemonic (C:\Users\Jackc ode_modules\@truffle\hdwallet-provider\src\index.ts:...


如何在 Foundry 中的 Sepolia 测试网上运行测试?

我知道可以在 Foundry 中的分叉测试网上运行测试 伪造测试 --fork-url SEPOLIA_RPC_URL 或者 forge test --rpc-url SEPOLIA_RPC_URL #与 --fork-url 结果相同 但如果我想要...


如何以编程方式调用junit5 @ParameterizedTest?

我有一堆junit 5测试,其中一些是参数化的,我想从java类中调用它们。 当保存在 src/test 中时,测试通过 IDE 或使用 gradle clean build 成功运行


Maven:在编译中排除 java 文件

我有一个java源文件夹,我希望将其从编译中排除。 我的文件夹位于 qa/apitests/src/main/java/api/test/omi 下。 我在 qa/bamtests 下的 pom.xml 中添加了以下条目...


使用 Visual Studio 2020 在 C++ 中使用 google test 设置/配置单元测试

如果您无法编译解决方案,例如收到未解决的外部错误,请查看答案部分并重新创建其中列出的步骤。


OpenQA.Selenium.NoSuchElementException:没有这样的元素:无法找到元素

我有一个网页,我正在尝试使用此练习网站 https://practicetestautomation.com/practice-test-login/ 使用 selenium 实现自动化,我的脚本中有等待条件,所以我不确定为什么


Osquery自定义路径安装窗口,有没有办法修改“Pidfile”和“osquery.db”的路径?

我尝试通过将默认 osquery 安装中的 osqueryd.exe 文件放入 C:\Program Files\Test oo estosqueryd.exe 来在自定义位置安装 osquery。然而,当我安装时...


使用组时无法识别 TestNG 参数

使用 testNG xml 运行测试套件时,测试将正常运行,并且 xml 文件中的所有参数均按预期使用。当我将分组添加到我的 @Test 方法并添加组时...


为什么 GAE appspot URL 路由到默认服务?

我正在将 python/django 应用程序的 3 个不同实例部署为项目中的 3 个不同服务。 app-devl 作为共享开发环境 app-test 作为测试环境 默认为


如何在具有预定义值的表单输入上使用State?

我想要一个带有默认值的表单,并且用户输入的任何值都会被捕获。这是我的代码: 从“preact/hooks”导入{useState}; 导出默认函数 test() { 合作...


重命名多个文件,但在 Bash 中仅重命名部分文件名

我知道如何重命名文件等,但我在这方面遇到了麻烦。 我只需要在 for 循环中重命名 test-this 。 测试-this.ext 测试-this.volume001+02.ext 测试-this.volume002+04.ext 测试-...


在 Powershell 中为 Test-NetConnection 或 5985 设置跨域超时

我已经运行了这个,但我更改了 PortOpen,因为如果系统关闭,这个块将需要很长时间才能运行。然而,在我改变之后,我以为我很好,直到我来测试......


如何在vue-i18n中使用@等特殊字符?

我正在使用 vue-i18n 来本地化我的表单。我有一个电子邮件字段,其中有一个占位符,其中包含一个包含 @ 符号的示例电子邮件地址。 emailPlaceholder:'例如:[email protected]'


VSCode - 重命名符号会跳过 Python 项目中的测试文件

在我的 Python 项目中,当我使用 VSCode 重命名符号时,更改不会传播到“测试文件”。更具体地说,如果 .py 文件位于名为 test 的目录中或名为 test_...


无法使用 GKE 集群中的 VPC 对等互连连接到 GCP 中的 Mongo Atlas

问题:我在 GKE 中的应用程序无法通过 VPC 对等互连与 mongo Atlas 连接,但是如果我使用 mongodb+srv://cluster0-pri.mongodb.net/test 从 GkE 集群中的 pod 手动运行 mongosh - -


如何在调用函数中通过名称引用局部变量?

我有下面的代码,在函数“test”按要求工作的情况下,而当“foreach”的工作被分解到函数中时,当变量超出范围时,事情就会停止工作。有没有...


如何将测试代码从一个模块导入到另一个模块而不将其暴露给生产代码?

TLDR:我在 logutils/test-logger_test.go 中放置了一个 TestLogger 结构,并尝试在authentication/login_tests.go 中引用它。当为身份验证模块构建测试时,编译器会抱怨


Nginx 入口控制器 - 无法使用主机名访问 AKS Azure 负载均衡器

我有一个私有 AKS 集群,并且正在使用 nginx 入口控制器。到目前为止,我已经做了以下事情。 安装 nginx 入口控制器 命名空间=jananath-test helm 升级 --安装 ingress-n...


新的 Microsoft Azure 机器人“在 Web 聊天中测试”错误:将此消息发送到您的机器人时出错:HTTP 状态代码 InternalServerError 500

我设置了一个新的单租户 Azure Bot,并使用 CI/CD 管道将 Bot Framework 解决方案部署到 azure Web 应用程序。我正在使用开箱即用的 Bot Builder 模板“Core Bot with Test”...


github 桌面错误“存储库似乎不再存在。您可能无权访问,或者它可能已被删除或重命名。”

我已经安装了GitHub Desktop作为上传本地项目工具,我上传了一个项目“F:/test”,在我的GitHub主页上可以显示成功,然后我删除了这个存储库。 但我重新发布...


选中/取消选中 mat-checkbox 未正确返回 true 或 false

我正在使用 Angular 15 和 Angular Material 14,下面是我用来显示复选框列表的 HTML 代码 我正在 Angular 15 和 Angular Material 14 工作,下面是我用来显示复选框列表的 HTML 代码 <div *ngFor="let control of checkboxArray.controls;let i = index" > <mat-checkbox [formControl]="control" (input)="validateInputs(notificationForm)" [checked]="control.value" (change)="control.checked=$event.checked;onCheckedChange(i);"> {{ checkboxItems[i].name }} </mat-checkbox> </div> 下面是Angular中onCheckedChange函数的代码 onCheckedChange(index: number) { this.sortCheckboxArray(); const checkboxItem = this.checkboxItems[index]; const control = this.checkboxArray.at(index); if (control) { if (control.value) { this.lists.push(checkboxItem.id.toString()); } else { this.lists.pop(checkboxItem.id.toString()); } } this.updateSubscriberGroupsCount(); this.cdr.detectChanges(); } 当我选中复选框时,在这个 onCheckedChange 函数中,control.value 始终返回 false。哪里出了问题?无法理解.. 这是一个工作版本,复选框逻辑工作正常,希望有帮助! 我们需要使用control.value获取表单组,但我们还需要访问内部表单控件,然后获取复选框值! import { CommonModule } from '@angular/common'; import { Component } from '@angular/core'; import { FormArray, FormControl, FormGroup, ReactiveFormsModule, } from '@angular/forms'; import { bootstrapApplication } from '@angular/platform-browser'; import 'zone.js'; import { MatCheckboxModule } from '@angular/material/checkbox'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, ReactiveFormsModule, MatCheckboxModule], template: ` <form [formGroup]="form"> <div formArrayName="array"> <div *ngFor="let control of checkboxArray.controls;let i = index" [formGroupName]="i"> <mat-checkbox formControlName="test" style="margin-bottom: 15px;" (change)="onCheckedChange(i);"> {{ checkboxItems[i].name }} </mat-checkbox> </div> </div> </form> `, }) export class App { name = 'Angular'; form = new FormGroup({ array: new FormArray([]), }); lists = []; checkboxItems: any = []; ngOnInit() { this.add(); this.add(); this.add(); } add() { this.checkboxArray.push( new FormGroup({ test: new FormControl(false), }) ); this.checkboxItems.push({ name: 'test' }); } get checkboxArray() { return this.form.get('array') as FormArray; } onCheckedChange(index: number) { // this.sortCheckboxArray(); // const checkboxItem = this.checkboxItems[index]; const control = this.checkboxArray.at(index); if (control) { if (control.value.test) { console.log('checked'); // this.lists.push(checkboxItem.id.toString()); } else { console.log('not checked'); // this.lists.pop(checkboxItem.id.toString()); } } // this.updateSubscriberGroupsCount(); // this.cdr.detectChanges(); } } bootstrapApplication(App); 堆栈闪电战


如何使用 XSLT 删除基于值的特定 XML 元素

假设我们有要转换的 XML: 测试 / 假设我们有要转换的 XML: <?xml version="1.0" encoding="UTF-8"?> <node> <field1>test</field1> <field2>/</field2> <field3>test2</field3> <field4>/<field4> </node> 我想使用 XSLT 1.0 对其进行转换,以便复制整个结构和所有值,除了具有值“/”的元素。 到目前为止,我已经找到了这个,我认为这离我需要的并不遥远,但它还没有工作。 <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:strip-space elements="*"/> <xsl:output indent="yes"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="//text()='/'" /> </xsl:transform> 所以我期望的输出是这样的: <?xml version="1.0" encoding="UTF-8"?> <node> <field1>test</field1> <field3>test2</field3> </node> 尝试此操作时,我收到未指定的错误(因为我正在使用免费的在线工具进行转换)。 //text()='/' 不是有效的位置路径。 在任何情况下,您想要删除元素,而不是文本节点 - 所以您应该使用类似的东西: <xsl:template match="*[.='/']" />


jQuery Ajax 在 php 同一页面上传递值 - 更新

如何找回: 如何找回: <div id="test"> <?php if (isset($_POST['sweets'])) { ob_clean(); echo $_POST['sweets']; exit; } ?> </div> <form id="a" action="" method="post"> <select name="sweets" onchange="change()" id="select1"> <option >Chocolate</option> <option selected="selected">Candy</option> <option >Taffy</option> <option >Caramel</option> <option >Fudge</option> <option >Cookie</option> </select> </form> <!-- Script --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script> function change() { var sweets = $("#select1").val(); $.ajax({ type: "POST", data: { sweets: sweets }, success: function(data) { $("#test").html(data); } }); } </script> 将值传递给 php 字符串: $string = $_POST['sweets']; <!-- I'm looking for this: --> 我希望这是可能的。我在 stackoverflow 和 google 上寻找答案,但找不到适合我的目的的答案。 对于同一个页面的ajax/PHP脚本,可以将PHP放在脚本的最前面,当有POST提交数据时以exit结束 为了使其更有意义,您应该返回与您通过 POST 提交的内容相关的内容(这是甜食的类型),作为示例,我们展示其一般定义。我们可以使用 switch,这是用于此目的的常用结构: switch ($string) { case "Chocolate": echo "Chocolate is made from cocoa beans, the dried and fermented seeds of the cacao tree"; break; case "Candy": echo "Candy is a sweet food made from sugar or chocolate, or a piece of this"; break; case "Taffy": echo "Taffy is a type of candy invented in the United States, made by stretching and/or pulling a sticky mass of a soft candy base"; break; case "Caramel": echo "Caramel is made of sugar or syrup heated until it turns brown, used as a flavouring or colouring for food or drink"; break; case "Fudge": echo "Fudge is a dense, rich confection typically made with sugar, milk or cream, butter and chocolate or other flavorings"; break; case "Cookie": echo "A cookie (American English) or biscuit (British English) is a baked snack or dessert that is typically small, flat, and sweet"; break; } exit; } ?> 所以以下是示例代码: <?php if (isset($_POST['sweets'])) { // ob_clean(); $string = $_POST['sweets']; switch ($string) { case "Chocolate": echo "Chocolate is made from cocoa beans, the dried and fermented seeds of the cacao tree"; break; case "Candy": echo "Candy is a sweet food made from sugar or chocolate, or a piece of this"; break; case "Taffy": echo "Taffy is a type of candy invented in the United States, made by stretching and/or pulling a sticky mass of a soft candy base"; break; case "Caramel": echo "Caramel is made of sugar or syrup heated until it turns brown, used as a flavouring or colouring for food or drink"; break; case "Fudge": echo "Fudge is a dense, rich confection typically made with sugar, milk or cream, butter and chocolate or other flavorings"; break; case "Cookie": echo "A cookie (American English) or biscuit (British English) is a baked snack or dessert that is typically small, flat, and sweet"; break; } exit; } ?> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <select name="sweets" onchange="change()" id="select1"> <option value="">Please select</option> <option >Chocolate</option> <option >Candy</option> <option >Taffy</option> <option >Caramel</option> <option >Fudge</option> <option >Cookie</option> </select> <br><br> <div id="test"></div> <script> function change() { var sweets = $("#select1").val(); $.ajax({ type: "POST", data: { sweets: sweets }, success: function(data) { $("#test").html(data); } }); } </script>


如何将“block”元素分组到“<p class="p">”元素中?

我想将 元素分组到 元素内部。如果 follow-sibling[1] 是 元素并且 我想将 <block> 元素分组到 <p class="p"> 元素内部。如果 <p class="p"> follow-sibling[1] 是 <block> 元素且 <p class="p1"> 值位于 <p class="p"> 元素中。 输入XML文件-: <root> <p class="p">aaaaaa</p> <block> <p>block</p> </block> <p class="p1"> bbb </p> <block> <p>block</p> </block> <p class="p1">bbb.</p> <p class="p">cccc</p> </root> 我想要下面的预期输出。 输出XML文件: <root> <p class="p">aaaaaa<block><p>block</p></block> bbb <block><p>block</p></block>bbb.</p> <p class="p">cccc</p> </root> 我们能否以另一种方式将逻辑纠正到输出上方,我在输出上方使用 XSLT: <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="p[@class='p']"> <xsl:choose> <xsl:when test="following-sibling::*[1][self::block]"> <xsl:text disable-output-escaping="yes">&lt;p&gt;</xsl:text> <xsl:apply-templates/> </xsl:when> <xsl:otherwise> <p><xsl:apply-templates select="@*|node()"/></p> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="p[@class='p1']"> <xsl:choose> <xsl:when test="following-sibling::*[1][self::p[@class='p']]"> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes">&lt;/p&gt;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:template> 以下内容似乎包装/分组了输入示例的正确节点,但我不确定它是否实现了您的要求,我还不太理解它们。 <xsl:template match="root"> <xsl:copy> <xsl:for-each-group select="*" group-starting-with="p[@class = 'p']"> <xsl:copy> <xsl:apply-templates select="node(), current-group() except ."/> </xsl:copy> </xsl:for-each-group> </xsl:copy> </xsl:template>


如何将 '<p class="p1">' 、 '<div class="disp-quote-p">/following-sibling::*[1][self::p[@class='p1']]' 包装/分组在单个 'p' 元素中

我正在包装节点 ' 、 '' 和 div[@class='disp-quote-p']/following-sibling::*[1][self::p[@class=' p1']] 里面... 我正在尝试将节点 <p class="p1">' , '<div class="disp-quote-p">' and div[@class='disp-quote-p']/following-sibling::*[1][self::p[@class='p1']] 包裹在单个 p 元素中。 输入 XML:- <root> <p class="p">aa</p> <p class="p1">Although:</p> <div class="disp-quote-p"> <p class="p">We had seen.</p> </div> <p class="p1">This dot.</p> <img src="a.png"/> <box>box</box> <p class="p">bb</p> </root> 我正在尝试将节点包装在单个 p 元素中的代码,但此节点 <p class="p1">This dot.</p> 与 <div class="disp-quote-p"> 节点一起包装。 <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="root"> <xsl:copy> <xsl:for-each-group select="*" group-starting-with="p[@class='p1']"> <xsl:for-each-group select="current-group()" group-adjacent="self::p[@class='p1'] or self::div[@class='disp-quote-p']"> <xsl:choose> <xsl:when test="self::p[@class='p1']"> <p><xsl:apply-templates select="node(), current-group() except ."/></p> </xsl:when> <xsl:otherwise> <xsl:copy-of select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:for-each-group> </xsl:copy> </xsl:template> 网址链接:[http://xsltransform.net/eiov64R/1] 预期输出:- <root> <p class="p">aa</p> <p>Although:<disp-quote><p class="p">We had seen.</p></disp-quote>This dot.</p> <img src="a.png"/> <box>box</box> <p class="p">bb</p> </root> 试试这个: <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="root"> <xsl:copy> <xsl:for-each-group select="*" group-adjacent="if(self::p[@class='p1'] or self::div) then -1 else position()"> <xsl:choose> <xsl:when test="self::p[@class='p1'] or self::div"> <p><xsl:apply-templates select="current-group()"/></p> </xsl:when> <xsl:otherwise> <xsl:copy-of select="current-group()"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:copy> </xsl:template> <xsl:template match="p[@class='p1']"> <xsl:apply-templates/> </xsl:template> <xsl:template match="div[@class='disp-quote-p']"> <xsl:element name="disp-quote"> <xsl:apply-templates/> </xsl:element> </xsl:template>


© www.soinside.com 2019 - 2024. All rights reserved.