У меня есть XML-файл, который я связал со схемой xsd. Я хочу создать xsl для схемы таким образом, чтобы в любом порядке, в котором я пишу xml, он выводился в таком порядке.
например:
'<employee>
<firstname>sultan</firstname>
<lastname>saadat</lastname>
</employee>'
Если указанный выше блок записан так:
<employee>
<lastname>saadat</lastname>
<firstname>sultan</firstname>
</employee>
Должно получаться таким же образом при преобразовании, а не таким образом, как оно анализируется? какие могут быть возможные решения?
возникли проблемы с этим XML-файлом
<?xml version="1.0" encoding="UTF-8"?>
<resume>
<professional-experience-section>
<section-name>PROFESSIONAL EXPERIENCE</section-name>
<enabled>true</enabled>
<company>
<name>Computer Sciences Corporation</name>
<city>New York</city>
<state>NY</state>
<country>United States</country>
<job-title>
<title>Senior Software Engineer</title>
<start-date>Aug 1996</start-date>
<end-date>May 2010</end-date>
<ongoing>false</ongoing>
<job-description>
<bullet-point>
<statement>C#, Visual Basic, Asp.net</statement>
</bullet-point>
<bullet-point>
<statement>Inspect completed work to ensure conformance to specifications, standards, and contract requirements.</statement>
</bullet-point>
<bullet-point>
<statement>Another Work Description.</statement>
</bullet-point>
</job-description>
</job-title>
</company>
<company>
<name>Acme</name>
<city>Silver Spring</city>
<state>MD</state>
<country>United States</country>
</company>
</professional-experience-section>
<education-section>
<section-name>EDUCATION</section-name>
<enabled>true</enabled>
<institution>
<name>Allston Community College</name>
<city>Akron</city>
<state>MA</state>
<country>United States</country>
<degree>Bachelor of Art in Marketing Candidate</degree>
<end-date>Jan 2020</end-date>
<ongoing>true</ongoing>
<expected-completion-date>Jan 2020</expected-completion-date>
<completed></completed>
<bullet-point>
<statement>detail of what i did at the allston community college</statement>
</bullet-point>
</institution>
</education-section>
<additional-skills-section>
<section-name>ADDITIONAL SKILLS</section-name>
<enabled>true</enabled>
<layout>1 Column</layout>
<bullet-point>
<statement>1</statement>
</bullet-point>
</additional-skills-section>
<custom-section>
<section-name>PUBLICATIONS</section-name>
<layout>2</layout>
<bullet-point>
<statement>test</statement>
</bullet-point>
</custom-section>
<custom-section>
<section-name>AWARDS</section-name>
<layout>2</layout>
<bullet-point>
<statement>test</statement>
</bullet-point>
</custom-section>
</resume>
Пример таблицы стилей для одного раздела, то же самое относится и к другим разделам:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/resume">
<xsl:value-of select="/resume/contact-information/full-name"/>
<xsl:value-of select="/resume/contact-information/address_line_1"/>
<xsl:value-of select="/resume/contact-information/address_line_2"/>
<xsl:value-of select="/resume/contact-information/city"/>
<xsl:value-of select="/resume/contact-information/state"/>
<xsl:value-of select="/resume/contact-information/country"/>
<xsl:value-of select="/resume/contact-information/phone"/>
<xsl:for-each select="/resume/professional-experience-section/company">
<!--for company name-->
<xsl:value-of select="name"/>
<xsl:value-of select="city"/>, <xsl:value-of select="state"/>
<xsl:value-of select="country"/>
<!--loop into job title-->
<xsl:for-each select="job-title">
<!--for job title-->
<xsl:value-of select="title"/>
<!--for job start date and job end date-->
<xsl:value-of select="start-date"/> – <xsl:value-of
select="end-date"/>
<!--Loop into job description-->
<xsl:for-each select="job-description">
<!--loop into each bullet point-->
<xsl:for-each select="bullet-point">
<xsl:value-of select="statement"/>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>