xml - sequence in transformation using xslt -


I am working with XML from XML XML conversion. I have XSD defined for the new converted XML. There is some predefined sequence / order for each element in XSD. How can I do the same sequence from XSD, while the XML conversion will appear?

I tried to organize the conversion sequence in the form of my XSD, but it turns out that the change sequence is not the same as the xslt execution sequence.

Appreciate your response

  & lt; Root & gt; & Lt; A1 & gt; & Lt; / A1> & Lt; B1 & gt; B & lt; / B1> & Lt; C1 & gt; C & lt; / C1> & Lt; D1 & gt; D & lt; / D1> & Lt; / Root & gt; & Lt; Root & gt; & Lt; A1 & gt; & Lt; / A1> & Lt; D1 & gt; D & lt; / D1> & Lt; B1 & gt; B & lt; / B1> & Lt; C1 & gt; C & lt; / C1> & Lt; / Root & gt;  

I tried the following based on your suggestion

   & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "root" & gt; & Lt; Xsl: Apply-Select Template = "A1, D1, C1, B1" /> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "A1" & gt; & Lt; A1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / A1> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "b1" & gt; & Lt; B1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / B1> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "c1" & gt; & Lt; C1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / C1> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "d1" & gt; & Lt; D1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / D1> & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt; XSLT processes your input documents and applies your templates so that you have to write your XSLT. In a way, it produces proper production, you have not provided any information about your input and how it shows the maps of the output you want, just because there is a schema for your output format while XSLT 2.0 schema-aware XSLT knows processing, which primarily means to validate input and / or output in the set of schemas or schemas, to be output according to the schema. Or is no magic to make it.  

For example if you have an input

  & lt; Foo & gt; & Lt; Child1 & gt; ... & lt; / Child1 & gt; & Lt; Child2 & gt; ... & lt; / Child2 & gt; & Lt; / Foo & gt;  

And you want to create

  & lt; Bar & gt; & Lt; Child2 & gt; ... & lt; / Child2 & gt; & Lt; Child1 & gt; ... & lt; / Child1 & gt; & Lt; / Bars & gt;  

Then, as foo

  & lt; Xsl: template match = "foo" & gt; & Lt; Bar & gt; & Lt; XSL: implemented-templates & gt; & Lt; Xsl: Select Sort = "Status ()" Order = "descending" /> & Lt; / XSL: implemented-templates & gt; & Lt; / Bars & gt; & Lt; / XSL: Templates & gt;  

Or for example

  & lt; Xsl: template match = "foo" & gt; & Lt; Bar & gt; & Lt; Xsl: Apply-Select Template = "Child2, Child 1" /> & Lt; / Bars & gt; & Lt; / XSL: Templates & gt;  

For such concrete samples that you have provided in one edit, you are almost there with some improvements

   & Lt; Xsl: template match = "node () | @ *" & gt; & Lt; XSL: Copy & gt; & Lt; Xsl: apply-select template = "node () | @ *" /> & Lt; / XSL: Copy & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "root" & gt; & Lt; Root & gt; & Lt; Xsl: Apply-Select Template = "A1, D1, C1, B1" /> & Lt; / Root & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "A1" & gt; & Lt; A1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / A1> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "b1" & gt; & Lt; B1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / B1> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "c1" & gt; & Lt; C1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / C1> & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "d1" & gt; & Lt; D1 & gt; & Lt; Xsl: applied-template / & gt; & Lt; / D1> & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;  

and an XSLT 2.0 processor such as Saxon 9 I

  & lt; Root & gt; & Lt; A1 & gt; & Lt; / A1> & Lt; D1 & gt; D & lt; / D1> & Lt; C1 & gt; C & lt; / C1> & Lt; B1 & gt; B & lt; / B1> & Lt; / Root & gt;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -