xslt

XSLT apply-templates in for-each

拥有回忆 提交于 2021-01-29 19:01:26
问题 I'm trying to write a simple XHTML to Simple Docbook translator (the input XHTML is a limited subset so it should be doable). I have this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" standalone="no"/> <!-- <xsl:strip-space elements="*"/> --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy>

Get XPath of XML Tag

試著忘記壹切 提交于 2021-01-29 18:09:02
问题 If I have an XML document like below: <foo> <foo1>Foo Test 1</foo1> <foo2> <another1> <test10>This is a duplicate</test10> </another1> </foo2> <foo2> <another1> <test1>Foo Test 2</test1> </another1> </foo2> <foo3>Foo Test 3</foo3> <foo4>Foo Test 4</foo4> </foo> How do I get the XPath of <test1> for example? So the output should be something like: foo/foo2[2]/another1/test1 I'm guessing the code would look something like this: public String getXPath(Document document, String xmlTag) { String

Java XML XSLT to generate HTML Report

纵然是瞬间 提交于 2021-01-29 17:47:28
问题 EDIT Now i know why people use string builder, using JAXB is a pain and very time consuming, at least for me it was because i have a very complex XML to generate. Appreciate the help :) I have a java application which collects user data. I also created a template XSL. Now i am stuck. What is my next step? Should i use the java to code to create an XML? If so, what kind of XML am i creating, i need my HTML to be strict at the end. Sorry if this is a duplicate, i couldn't find anything and i'm

XSLTProcessor::transformToUri(): Memory allocation failed : reaching arbitrary MAX_URI_LENGTH limit

萝らか妹 提交于 2021-01-29 17:36:45
问题 I have some XML files that I need to "transform" in Html and display on screen. I have developed a simple script that works -almost- all of the times, using DOMDocument and XSLTProcessor . The problem is that sometimes it gives this error, and the resulting html is only a part of the complete content: XSLTProcessor::transformToUri(): Memory allocation failed : reaching arbitrary MAX_URI_LENGTH limit in /var/www/test/index.php on line 14 This is a working copy of my script, which gives the

dependency graph traversal in XSLT for copying related elements of an XML model

孤街浪徒 提交于 2021-01-29 17:34:52
问题 I want to demonstrate XSL powerfullness for data exploration by solving the following problem: Given an xml file that describes some kind of "entity-relashionship" model, and for one entity in that model given by a name (assuming an attribute of the XML schema is used as identifier), I want a transformation that produce a new XML model that contains the given entity, plus all of its relatives as per the "Transitive closure of the dependencies relationship" of that given entity. For example,

How to do sort(as alphabetical odder) within a for loop as expected below in xslt or xsl-fo?

无人久伴 提交于 2021-01-29 16:23:21
问题 I want to create a table Which contain two columns as product type and number of quantity in XSL-Fo. In the XML input file Type node contain 00 then in the table the product should be come like "Other" if Type element value is 00 then "Other" like wise 51 = Business Loan – General 05 = Personal Loan I want to see all product in alphabetical ascending odder. This is my Input XML <product> <months> <Type>00</Type> <Number>2</Number> </months> <months> <Type>51</Type> <Number>2</Number> </months

Is there any option to embedding xhtml in html?

爱⌒轻易说出口 提交于 2021-01-29 14:00:37
问题 I have an XML file, which has xsl style sheet with css and html. I wanted to embed this file in existing html. If any one has idea please help me to solve this problem. 回答1: A very detailed answer to this question can be found in Norm Walsh's W3C task force report https://www.w3.org/TR/html-xml-tf-report/ But for a one-line summary, section 2.4 asks "2.4 How can islands of XML be embedded in HTML?" and answers "In order to conceal the XML markup from an HTML5 parser's attempts to correct

XSLT - How to treat inline/escaped XML within a node as nested nodes

只愿长相守 提交于 2021-01-29 13:45:11
问题 New to xslt - not enjoying it so far. Trying to preserve some HTML (table) formatting being received by an application that converts to PDF. Need an xslt way of interpreting escaped HTML/XML data within an XML node as further child nodes? Have tried a v3 parse-xml() on that node. Have tried a v1 search/replace template to convert < into < etc. Have tried disable-output-escaping="yes" - nope. Nothing appears to work for some reason. Source XML: <?xml version="1.0" encoding="windows-1252"?>

Getting the serialization properties from Saxon transformation

為{幸葍}努か 提交于 2021-01-29 13:16:46
问题 I have following XSL stylesheet: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"> <xsl:output encoding="UTF-8" method="xml"/> <xsl:template match="/"> <test/> </xsl:template> </xsl:stylesheet> I am using Saxon 9.9 to transform it like this. public String transform(InputStream input, InputStream stylesheet, OutputStream output){ Processor p = new Processor(false); XsltCompiler c = p.newXsltCompiler(); XsltExecutable e = c

XSLT 1.0 - Output Count of Value Uniqueness in a Node with Vanilla XSLT 1.0 or PHP XSLT

寵の児 提交于 2021-01-29 12:54:52
问题 I have a node in my XML data named this node contains a unique value, say 45678. Via XSLT, I'd like to only include this node's data, if 45678 is found more than once (1) in the complete data set. The end result can modify the existing node, or create a new one called . The end result of this data creates "Parent with children" products. The productId value groups all similar products together, the problem, is that sometimes there is only 1 product with that key, and I shouldn't create a