Articles of xml

如何使用nginx在XSL转换的样式表上获得“text / plain”输出?

我试图编写XSL样式表来将结果转换为简单的纯文本string,并且在Chrome和Opera上出现以下错误 : 此页面包含以下错误: 第1行上的错误:文档末尾的额外内容下面是页面的渲染,直到第一个错误。 本文档是作为XSL转换的结果而创build的。 给出的行和列号来自转换后的结果。 而在Firefox上运行良好 。 为什么? XSL是: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:apply-templates select="rtmp"/> </xsl:template> <xsl:template match="rtmp"> <xsl:apply-templates select="server"/> </xsl:template> <xsl:template match="server"> <xsl:apply-templates select="application"/> </xsl:template> <xsl:template match="application"> <xsl:apply-templates select="live"/> </xsl:template> <xsl:template match="live"> <xsl:apply-templates select="stream"/> </xsl:template> <xsl:template match="stream"> <xsl:choose> <xsl:when test="publishing"><xsl:value-of select="name"/>:<xsl:value-of select="nclients – 1"/>, </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet> 而nginx的conf是: location /live { […]

nginx 502错误的网关错误。 我的缓冲区应该多大?

我有一个Nginx的服务器,唯一的目的是读取XML并将其放入数据库中。 如果文件很小,比方说100MB一切正常。 但是,如果我试图SimpleXMLELement大约700MB的文件,我得到一个502错误的网关警告。 我读了这个问题,并摆弄下面的设置,但它没有帮助。 我的缓冲区应该更大? 如:700M或什么的? nginx.conf(在http {}中): fastcgi_buffers 128 128k; fastcgi_buffer_size 128k; fastcgi_connect_timeout 3000; fastcgi_send_timeout 3000; fastcgi_read_timeout 3000; 我有ini_set("memory_limit", "-1"); 在我的PHP脚本和php_admin_value[memory_limit] = 2042M在php-fpm.conf [03-Jul-2015 11:53:44] WARNING: [pool www] child 6327 exited on signal 9 (SIGKILL) after 19.047513 seconds from start [03-Jul-2015 12:16:12] WARNING: [pool www] child 6518 exited on signal 9 (SIGKILL) after 23.669892 […]

更改nginx的autoindex输出格式

我想通过http共享文件夹内容。 我已经安装了nginx和autoindex并将其configuration到我的文件夹。 问题是需要我的HTML文件与文件/文件夹列表,但我想要一些具有相同信息的XML。 是否有可能使用标准的nginx工具,或者我应该实施一些脚本来解决这个问题?

需要在Linux环境中用Perl脚本修改几个XML文件

我有几个名为TC_Circle1 , TC_Circle2 ,TC_Point1等XML文件在目录中,我想使用脚本来更新每个文件中的开始和结束date。 开始date和结束date在每个文件内部和标签中。 我在使用Sun机器时遇到了一个脚本,但它不适用于新的HP Linux机器。 它不显示任何错误,不会更改date。 我需要帮助让它在Linux中工作。 剧本: #!/usr/local/bin/perl $numArgs = @ARGV; if ($numArgs != 2) { print "Usage: replace_default_date.pl DEFAULT_START_DATE DEFAULT_STOP_DATE\n"; } @filenames = `ls TC*`; chomp(@filenames); foreach $file (@filenames) { open(REGFILE, "$file") || die "Cannot open |$file|"; @lines = <REGFILE>; close(REGFILE); open(WRITEFILE), ">$file") || die "Cannot open |$file|"; foreach $line (@lines) […]

从纯文本日志文件中提取xml块

我有一个具有SOAP请求/响应条目的日志: [2015-02-03 19:05:13] TIME:03.02.2015 19:05:13, RAW_REQUEST:<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="pay_parent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="providers"><SOAP-ENV:Body><!– … –> </SOAP-ENV:Body></SOAP-ENV:Envelope> , uid:0de7d51a-abb6-11e4-a436-005056936d96, === 我想提取所有的XML到一个大的XML文件(提取块和包装根…标签)。 但是我也需要日志logging的date。 我想(我可以用手添加根xmlns属性)来实现相同的结果: <Records xmlns="" …> <Record datetime="2015-02-03 19:05:13"> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="pay_parent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="providers"><SOAP-ENV:Body> <!– Other xml data –> </SOAP-ENV:Body></SOAP-ENV:Envelope> </Record> … </Records>

合并XML文件并删除重复的行

我正在使用以下脚本来合并XML文件。 有5种不同的XML文件types,ItemAvailability.xml,ItemUpsert.xml,ItemCatDesc.xml,ItemPrice.xml和ItemDelete.xml。 我怎样才能有相同的脚本从组合的XML文件中删除重复的行? 我真的只需要从ItemAvailability.xml文件中删除重复项,脚本运行15分钟的时间间隔cron作业。 任何想法都会有所帮助。 使用@Sahil M编辑的脚本只在运行ItemAvailability.xml时起作用,但是当我一起运行所有的XML文件时,出现以下错误: Traceback (most recent call last): File "/var/www/script/mergeXML.py", line 24, in <module> run(sys.argv[1:]) File "/var/www/script/mergeXML.py", line 17, in run if ( (row[0].text, row[1].text) ) in withoutDuplicates: File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 266, in __getitem__ return self._children[index] IndexError: list index out of range @Sahil M更新脚本 #!/usr/bin/env python import sys from xml.etree import […]

xmlstarlet XPathexpression式select单个结果而不是多个

我有一个像这样的结构的XML文件: <?xml version="1.0" encoding="UTF-8"?> <hudson> <authorizationStrategy> <roleMap type="globalRoles"> <role name="Employees"> <assignedSIDs> <sid>abc</sid> <sid>bcd</sid> </assignedSIDs> </role> </roleMap> <roleMap type="projectRoles"> <role name="test1" pattern=".*"> <assignedSIDs> <sid>abc</sid> <sid>zxc</sid> </assignedSIDs> </role> <role name="test2" pattern=".*"> <permissions/> <assignedSIDs> <sid>abc</sid> <sid>ghi</sid> </assignedSIDs> </role> <role name="test3" pattern=".*"> <permissions/> <assignedSIDs> <sid>abc</sid> </assignedSIDs> </role> </roleMap> </authorizationStrategy> </hudson> 以前,我没有给出整个结构和我遇到的xpath解决scheme,没有给出我期望的结果(在我的系统上,但它给了回答我的问题的人)在下面的链接search标签使用XmlStarlet基于子节点值的属性值 正如在那个链接中提到的,我想根据sid标签的值来查找angular色标签名称属性。 例如:如果我searchabc,查询必须返回Employees,test1,test2和test3。 这是我使用的脚本: xmlstarlet sel -t -v "//role[.//sid […]

如何在Linux中的多行查找和replace文本?

我正在阅读一个XML文件,并希望find此属性并将值50replace为45之前: <name>ipc.client.connect.max.retries</name> <value>50</value> 后: <name>ipc.client.connect.max.retries</name> <value>45</value> 我在用 pcregrep -M '<name>ipc.client.connect.max.retries</name>.*(\n|.)*<value>45</value>' core-site.xml findstring。 我试过了 sed 's/$string1/$string2' core-site.xml 它不工作

XSLT处理/从ruby

任何人都可以推荐一个有效的方法来执行Ruby应用程序内的XML数据的XSLT转换? XSLgem(REXSL)目前尚不可用,虽然我看到一个或两个实现它的项目,但我很谨慎使用它们。 一位朋友向Perl推荐了一个shell,但是我担心资源。 这是一个Linux环境。

如果使用标准的linux工具包含特定的string,如何从xml文件中提取整个logging

我使用包含书籍数据的XML文件。 在调查数据损坏问题时,我经常需要提取包含特定string的整个logging​​。 我正在努力做到这一点,因为我对bash脚本的知识非常有限,完全缺乏其他编程语言(如perl)的知识。 我有标准的用户访问Linux的一个盒子(RHEL 4),没有获得安装任何东西的权限。 使用这个盒子上的标准工具/语言,任何人都可以解释我如何寻找一个特定的string,并从文件中提取任何可能包含它的整个logging​​? 例如从下面的文件中提取包含“Smith”的整个logging​​。 示例数据: <File> <Product> <Ref>1</Ref> <Title>My Life</Title> <Series>Life Stories</Series> <Author>John Smith</Author> <Price>5.99</Price> </Product> <Product> <Ref>2</Ref> <Title>A Story</Title> <Author>Fred Bloggs</Author> <Price>16.99</Price> </Product> <Product> <Ref>3</Ref> <Title>Book 1</Title> <Author>Jane Smith</Author> <Price>10.99</Price> </Product> </File> 要求的输出: <Product> <Ref>1</Ref> <Title>My Life</Title> <Series>Life Stories</Series> <Author>John Smith</Author> <Price>5.99</Price> </Product> <Product> <Ref>3</Ref> <Title>Book 1</Title> <Author>Jane Smith</Author> <Price>10.99</Price> </Product> […]