xslt

XSLT Insert element only if it doesn't exist

一个人想着一个人 提交于 2020-02-01 06:20:48
问题 I have a source document: <?xml version="1.0"?> <source> <ItemNotSubstituted/> <ItemToBeSubstituted Id='MatchId' /> </source> And a stylesheet containing content I want to substitute into the source: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" omit-xml-declaration="no" version="1.0"/> <xsl:preserve-space elements="//*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*

XSLT Insert element only if it doesn't exist

六眼飞鱼酱① 提交于 2020-02-01 06:20:40
问题 I have a source document: <?xml version="1.0"?> <source> <ItemNotSubstituted/> <ItemToBeSubstituted Id='MatchId' /> </source> And a stylesheet containing content I want to substitute into the source: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" omit-xml-declaration="no" version="1.0"/> <xsl:preserve-space elements="//*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*

Parse XML file to get all Namespace information

瘦欲@ 提交于 2020-02-01 05:28:26
问题 I want to be able to get all namespace information from a given XML File. So for example, if the input XML File is something like: <ns1:create xmlns:ns1="http://predic8.com/wsdl/material/ArticleService/1/"> <ns1:article xmlns:ns1="xmlns:ns1='http://predic8.com/material/1/"> <ns1:id>1</ns1:id> <description>bar</description> <name>foo</name> <ns1:price> <amount>00.00</amount> <currency>USD</currency> </ns1:price> <ns1:price> <amount>11.11</amount> <currency>AUD</currency> </ns1:price> </ns1

XSLT 1.0 - Create a Unique, Ordered List

℡╲_俬逩灬. 提交于 2020-01-30 09:46:47
问题 I'm trying to create a transform where I generate an ordered unique list (where a hyphen separates two values. I have source <?xml version="1.0"?> <results> <result> <Name>Blue</Name> <Author>Hat</Author> <TrackNum>5</TrackNum> </result> <result> <Name>Red</Name> <Author>Car</Author> <TrackNum>2</TrackNum> </result> <result> <Name>Blue</Name> <Author>Hat</Author> <TrackNum>345</TrackNum> </result> </results> And want the output (ordered by 'Name') :: Blue - Hat :: Red - Car XLST - This

How to edit specific xml using xpath

China☆狼群 提交于 2020-01-30 08:27:05
问题 I have got below xml which is genrated using xslt function json-to-xml(). I need to update this xml as shown in Result xml using given xpaths. I need the solution in java or xslt. Any help would be much appreciated. XML <?xml version="1.0" encoding="UTF-8"?> <map xmlns="http://www.w3.org/2005/xpath-functions"> <map key="Response"> <map key="Headers"> <string key="server">Lisa</string> <string key="Status-Code">200</string> <string key="Content-Type">applicaton/json</string> </map> <map key=

XSLT unable to group/sort nodes based on value

浪尽此生 提交于 2020-01-30 08:24:05
问题 I'm trying to transform this xml. However I'm having formatting issues. Could someone please guide me to solve this problem. Thanks in advance <?xml version="1.0" encoding="windows-1252"?> <XML> <Attributes> <Attribute> <id>5</id> <Name>Buyer ID</Name> <Type>common</Type> <Value>Lee</Value> </Attribute> <Attribute> <id>331</id> <Name>Enviornment</Name> <Type>common</Type> <Value>Development</Value> </Attribute> <Attribute> <id>79</id> <Name>Retail</Name> <Type>common</Type> <Value></Value> <

XSLT Namespaces

萝らか妹 提交于 2020-01-30 05:19:57
问题 I have a basic question about XSLT Namespaces. XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="myNamespace" exclude-result-prefixes="x"> <xsl:template match="/"> <newNode> <xsl:value-of select="x:Node1/x:Node2" /> </newNode> </xsl:template> </xsl:stylesheet> This XSLT works correctly when I apply it to: <Node1 xmlns="myNamespace"> <Node2>ValueIWant</Node2> </Node1> But it does not find "ValueIWant" when I apply it to: <ns0:Node1 xmlns:ns0=

XSLT Namespaces

做~自己de王妃 提交于 2020-01-30 05:19:10
问题 I have a basic question about XSLT Namespaces. XSLT: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="myNamespace" exclude-result-prefixes="x"> <xsl:template match="/"> <newNode> <xsl:value-of select="x:Node1/x:Node2" /> </newNode> </xsl:template> </xsl:stylesheet> This XSLT works correctly when I apply it to: <Node1 xmlns="myNamespace"> <Node2>ValueIWant</Node2> </Node1> But it does not find "ValueIWant" when I apply it to: <ns0:Node1 xmlns:ns0=

Print numbers from one to one million

北城以北 提交于 2020-01-28 02:45:29
问题 Assume you have a highly synthetic task to print numbers from 1 to 1.000.000 without appropriate input XML. Of course, straight-forward recursion will fail due to, ironic enough, stack overflow. I came up with the solution listed below: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:variable name="end" select="number(1000000)"/> <xsl:template match="/"> <xsl:call-template name="batches"/>

how transform from xml to json with xsl and removing the item/record labels

北城以北 提交于 2020-01-25 18:48:33
问题 Thanks to the excellent answer provided by Tim C in how transform from xml based on attributes to json and ignore the attributes from especific elements by using XSLT/XSL, I could learn how to transform my input xml to a json and excluding the item attributes during transformation. Kindly, see the input xml file below. Please, how can I do exact same transformation but ignoring the "aa" and "bbb" in the output json? I mean, how do I exclude during xml transformation to json the record