xpath-2.0

Can't get correct XSLT output

霸气de小男生 提交于 2020-01-04 15:27:28
问题 I have a XML like this: <?xml version="1.0" encoding="UTF-8"?> <Section> <Chapter> <nametable> <namerow> <namecell stuff="1"> <entity>A</entity> </namecell> <namecell stuff="2"> <entity>B</entity> </namecell> </namerow> </nametable> </Chapter> </Section> My XSLT is like this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:apply-templates select="Section/Chapter/

Does libxml2 support XPath 2.0 or not?

99封情书 提交于 2019-12-30 06:11:20
问题 I've tried to use the XPath 2.0 exp //span/string(.) in libxml2 , but it doesn't work. So, my question is: does libxml2 support XPath 2.0 or not? 回答1: As far as I know -- not. The prevailing majority of XPath 2.0 implementations are part of XSLT 2.0 processors or XQuery processors. 回答2: According to this 2007 email from the maintainer of libxml2, libxml2 does not, and will not, support XPath 2.0. 回答3: you might be interested in an XPath 2.0 extension to libxml2 - however, 2 caveats apply: it

How do I find the number of elements in a <xs:list> using XSLT?

人走茶凉 提交于 2019-12-23 20:33:10
问题 I have an XML schema that contains the following type : <xs:simpleType name="valuelist"> <xs:list itemType="xs:double"/> </xs:simpleType> A sample XML fragment would be: <values>1 2 3.2 5.6</values> In an XSLT transform, how do I get the number of elements in the list? How do I iterate over the elements? 回答1: I. XPath 2.0 (XSLT 2.0) solution : count(tokenize(., ' ')) II. XPath 1.0 (XSLT 1.0) solution : string-length() - string-length(translate(normalize-space(), ' ', '')) + 1 As for iteration

How to use XPath 2.0 Methods in .NET 4.0?

北城以北 提交于 2019-12-23 09:27:05
问题 I am using .NET 4.0 and I would like to use XPath 2.0 methods such as ([Matches()][1], [upper-case()][2], [lower-case()][3]) when trying to find elements in a document. Example XPath: "/MyDocument/MyNode[matches(@MyAttribute, 'MyValue', 'i')]" I have tried using: System.Xml.XPath.XPathNavigator.Compile() System.Xml.XmlDocument.SelectNodes() System.Xml.Linq.XDocument.SelectElements() But I basically throw the exception "UndefinedXsltContextException" (or something similar). Can this be done in

Apache Camel Xpath 2.0 with Saxon does not look to work in RouteBuilder / Predicates

南楼画角 提交于 2019-12-21 22:23:22
问题 I am using ServiceMix 4.5.3 which includes Camel 2.10.7 and I am able to make XSLT 2.0 transformations with the Saxon library using the option endpoint like this: ... to("xslt:stylesheet.xsl?transformerFactoryClass=net.sf.saxon.TransformerFactoryImpl") ... However when I try to use the xpath function like this: private Namespaces ourNS = new Namespaces("myns", "urn:com:company:domain:namespace:myns/1"); // ... some code ... // Make a predicate to filter according a header : // The code

Fragment input xhtml to seperate xhtml files with ancestor nodes deails

不问归期 提交于 2019-12-14 02:32:33
问题 Can someone help me on this. Really appreciated. Requirement: To generate separate html files for each pal:fragment element, for the source document attached ,the files gets name based on @fragment-id which is present on the pal:fragment elements. The 'pal:fragment' can be nested, wrapped with 'div' element. The fragmented file not only should include all child elements of pal:fragment, but also should include its ancestor 'div' element. Each separate file generated from 'pal:fragment' should

comma operator in xpath, is it like c?

…衆ロ難τιáo~ 提交于 2019-12-13 19:53:59
问题 <xsl:variable name="html-output-name" select="(if(@index and @index eq 'true') then concat($default-name, '.html') else (), @html-output-name, @output-name, $default-html)[1]" /> I see what the 'if' is doing, but I'm not sure how to make sense of the rest of the items in the command, and then the [1] at the end. Does this add up to 'the first non-empty item in the list?" 回答1: From http://www.w3.org/TR/xpath20/#construct_seq Definition: One way to construct a sequence is by using the comma

finding maximum depth of chapter

大憨熊 提交于 2019-12-13 15:24:04
问题 everyone . In this case ,I want to conpute the maxximun depth of the chapter.For instance, a book without chapters has height 0 . A book only has chapters with no sections ,the height should be 1.The folowing is xml: <book title="D"> <author> <name>abc</name> </author> <chapter title="chapter1"> <section title="section1.1"/> <section title="section1.2"> <section title="section1.2.1"/> <section title="section1.2.2"/> </section> <section title="section1.3"> <section title="section1.3.1"/> <

How to concatenate two node-sets such that order is respected?

喜你入骨 提交于 2019-12-13 13:25:42
问题 My understanding has been that, despite the fact that XSLT's "node-sets" are called "sets", they are, in fact, ordered lists of nodes (which is why each node is associated with an index). I've therefore been trying to use the "|" operator to concatenate node-sets such that the order of the nodes is respected. What I am attempting to accomplish is something like the following JavaScript code: [o1,o2,o3].concat([o4,o5,o6]) Which yields: [o1,o2,o3,o4,o5,o6] But, consider the following reduced

Total of true and false in current time

送分小仙女□ 提交于 2019-12-13 09:08:44
问题 I have got this XML document. Is there way how to sort the nodes by ascending time and by brand and then count how many cars (samples), true and false was in this time from start time (always the lowest time in the group)? <?xml version="1.0" encoding="UTF-8"?> <trade> <car time="1950" brand="audi" trend="true"> </car> <car time="1200" brand="renault" trend="true"> </car> <car time="1000" brand="audi" trend="true"> </car> <car time="2800" brand="renault" trend="true"> </car> <car time="2000"