Note that there are some explanatory texts on larger screens.

plurals
  1. POxsd & xml with element order change
    text
    copied!<p>I've an xml file which i have bound to an xsd schema. I want to create an xsl for the schema in such a way that whatever order i write the xml in it comes printed out in that order for example:</p> <pre><code>'&lt;employee&gt; &lt;firstname&gt;sultan&lt;/firstname&gt; &lt;lastname&gt;saadat&lt;/lastname&gt; &lt;/employee&gt;' </code></pre> <p>If the above block is written like this:</p> <pre><code> &lt;employee&gt; &lt;lastname&gt;saadat&lt;/lastname&gt; &lt;firstname&gt;sultan&lt;/firstname&gt; &lt;/employee&gt; </code></pre> <p>It should come out in the same way when transformed and not in the wayy it is parsed? what could be the possible solutions?</p> <p>having trouble with this xml file </p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;resume&gt; &lt;professional-experience-section&gt; &lt;section-name&gt;PROFESSIONAL EXPERIENCE&lt;/section-name&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;company&gt; &lt;name&gt;Computer Sciences Corporation&lt;/name&gt; &lt;city&gt;New York&lt;/city&gt; &lt;state&gt;NY&lt;/state&gt; &lt;country&gt;United States&lt;/country&gt; &lt;job-title&gt; &lt;title&gt;Senior Software Engineer&lt;/title&gt; &lt;start-date&gt;Aug 1996&lt;/start-date&gt; &lt;end-date&gt;May 2010&lt;/end-date&gt; &lt;ongoing&gt;false&lt;/ongoing&gt; &lt;job-description&gt; &lt;bullet-point&gt; &lt;statement&gt;C#, Visual Basic, Asp.net&lt;/statement&gt; &lt;/bullet-point&gt; &lt;bullet-point&gt; &lt;statement&gt;Inspect completed work to ensure conformance to specifications, standards, and contract requirements.&lt;/statement&gt; &lt;/bullet-point&gt; &lt;bullet-point&gt; &lt;statement&gt;Another Work Description.&lt;/statement&gt; &lt;/bullet-point&gt; &lt;/job-description&gt; &lt;/job-title&gt; &lt;/company&gt; &lt;company&gt; &lt;name&gt;Acme&lt;/name&gt; &lt;city&gt;Silver Spring&lt;/city&gt; &lt;state&gt;MD&lt;/state&gt; &lt;country&gt;United States&lt;/country&gt; &lt;/company&gt; &lt;/professional-experience-section&gt; &lt;education-section&gt; &lt;section-name&gt;EDUCATION&lt;/section-name&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;institution&gt; &lt;name&gt;Allston Community College&lt;/name&gt; &lt;city&gt;Akron&lt;/city&gt; &lt;state&gt;MA&lt;/state&gt; &lt;country&gt;United States&lt;/country&gt; &lt;degree&gt;Bachelor of Art in Marketing Candidate&lt;/degree&gt; &lt;end-date&gt;Jan 2020&lt;/end-date&gt; &lt;ongoing&gt;true&lt;/ongoing&gt; &lt;expected-completion-date&gt;Jan 2020&lt;/expected-completion-date&gt; &lt;completed&gt;&lt;/completed&gt; &lt;bullet-point&gt; &lt;statement&gt;detail of what i did at the allston community college&lt;/statement&gt; &lt;/bullet-point&gt; &lt;/institution&gt; &lt;/education-section&gt; &lt;additional-skills-section&gt; &lt;section-name&gt;ADDITIONAL SKILLS&lt;/section-name&gt; &lt;enabled&gt;true&lt;/enabled&gt; &lt;layout&gt;1 Column&lt;/layout&gt; &lt;bullet-point&gt; &lt;statement&gt;1&lt;/statement&gt; &lt;/bullet-point&gt; &lt;/additional-skills-section&gt; &lt;custom-section&gt; &lt;section-name&gt;PUBLICATIONS&lt;/section-name&gt; &lt;layout&gt;2&lt;/layout&gt; &lt;bullet-point&gt; &lt;statement&gt;test&lt;/statement&gt; &lt;/bullet-point&gt; &lt;/custom-section&gt; &lt;custom-section&gt; &lt;section-name&gt;AWARDS&lt;/section-name&gt; &lt;layout&gt;2&lt;/layout&gt; &lt;bullet-point&gt; &lt;statement&gt;test&lt;/statement&gt; &lt;/bullet-point&gt; &lt;/custom-section&gt; &lt;/resume&gt; </code></pre> <p>Sample Stylesheet for one section, same goes for other sections:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/resume"&gt; &lt;xsl:value-of select="/resume/contact-information/full-name"/&gt; &lt;xsl:value-of select="/resume/contact-information/address_line_1"/&gt; &lt;xsl:value-of select="/resume/contact-information/address_line_2"/&gt; &lt;xsl:value-of select="/resume/contact-information/city"/&gt; &lt;xsl:value-of select="/resume/contact-information/state"/&gt; &lt;xsl:value-of select="/resume/contact-information/country"/&gt; &lt;xsl:value-of select="/resume/contact-information/phone"/&gt; &lt;xsl:for-each select="/resume/professional-experience-section/company"&gt; &lt;!--for company name--&gt; &lt;xsl:value-of select="name"/&gt; &lt;xsl:value-of select="city"/&gt;, &lt;xsl:value-of select="state"/&gt; &lt;xsl:value-of select="country"/&gt; &lt;!--loop into job title--&gt; &lt;xsl:for-each select="job-title"&gt; &lt;!--for job title--&gt; &lt;xsl:value-of select="title"/&gt; &lt;!--for job start date and job end date--&gt; &lt;xsl:value-of select="start-date"/&gt; – &lt;xsl:value-of select="end-date"/&gt; &lt;!--Loop into job description--&gt; &lt;xsl:for-each select="job-description"&gt; &lt;!--loop into each bullet point--&gt; &lt;xsl:for-each select="bullet-point"&gt; &lt;xsl:value-of select="statement"/&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; &lt;/xsl:for-each&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload