Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Не получается полностью создать xsl. Прошу помощи / 22 сообщений из 22, страница 1 из 1
03.05.2012, 21:03
    #37781222
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Обращаюсь к опытным участникам форума, например _Vasilisk_ и др., которые дают простые и понятные рекомендации для начинающих (пенсионер, мне 62).
Необходимо преобразовать файл xml другой xml. Не получается полностью создать xsl.
Копирует до отметки в xsl <!-- далее не получается -->
исходный файл.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='file.xsl'?>
<records>
<record>
<language>rus</language>
<publisher>Kharkov Regional Branch of the National Olympic Committee of Ukraine </publisher>
<journalTitle> Fiziceskoe vospitanie studentov</journalTitle>
<issn>20755279</issn>
<publicationDate>2012-04-29</publicationDate>
<volume>2</volume>
<documentType>article</documentType>
<startPage>100</startPage>
<endPage>103</endPage>
<authors>
<author>
<affiliationId>1</affiliationId>
<name>Tolkunova I.V.</name>
<email>Olya@mail.ru<;/email>
<affiliationName>Kharkov National University</affiliationName>
</author>
<author>
<affiliationId>2</affiliationId>
<name>Krasnitskaya O.V.</name>
<email>yui@ukr.net<;/email>
<affiliationName>Kharkov National Aerospace University</affiliationName>
</author>
<author>
<affiliationId>3</affiliationId>
<name>Golets A.V.</name>
<email>asfg@gmai.com<;/email>
<affiliationName>National University of Physical Education and Sport of Ukraine</affiliationName>
</author>
</authors>
<affiliationsList>
<affiliationName affiliationId="1">University</affiliationName>
</affiliationsList>
<title lang="ENG">Subconscious defence for sportsmen</title>
<abstract lang="ENG">The questions of necessity of study of reasons of subconscious defence of men and women of sportsmen and their gender distinctions are considered. It is marked that subconscious defence is one of major criteria of success of competition activity and achievement of high sporting result. </abstract>
<keywords lang="ENG">
<keyword>subconscious</keyword>
<keyword>defence</keyword>
<keyword>role</keyword>
<keyword>conflict</keyword>
<keyword>self-appraisal</keyword>
</keywords>
<fullTextUrl>12tivsds.pdf</fullTextUrl>
</record>
<record>
.................
</record>
</records>


НУЖЕН ТАКОЙ ФАЙЛ:
<?xml version="1.0" encoding="UTF-8"?>
<records>
<record>
<language>rus</language>
<publisher>Kharkov Regional Branch of the National Olympic Committee of Ukraine </publisher>
<journalTitle> Fiziceskoe vospitanie studentov</journalTitle>
<issn>20755279</issn>
<publicationDate>2012-04-29</publicationDate>
<volume>2</volume>
<startPage>100</startPage>
<endPage>103</endPage>
<documentType>article</documentType>
<title language="eng">Subconscious defence for sportsmen</title>
<authors>
<author>
<name>Tolkunova I.V.</name>
<email>Olya@mail.ru<;/email>
<affiliationId>1</affiliationId>
</author>
<author>
<name>Krasnitskaya O.V.</name>
<email>yui@ukr.net<;/email>
<affiliationId>2</affiliationId>
</author>
<author>
<name>Golets A.V.</name>
<email>asfg@gmai.com<;/email>
<affiliationId>3</affiliationId>
</author>
</authors>
<affiliationsList>
<affiliationName affiliationId="1">Kharkov National University</affiliationName>
<affiliationName affiliationId="2">Kharkov National Aerospace University</affiliationName>
<affiliationName affiliationId="3">National University of Physical Education and Sport of Ukraine</affiliationName>
</affiliationsList>
<abstract lang="ENG">The questions of necessity of study of reasons of subconscious defence of men and women of sportsmen and their gender distinctions are considered. It is marked that subconscious defence is one of major criteria of success of competition activity and achievement of high sporting result. </abstract>
<fullTextUrl format="pdf"> http://nbuv.gov.ua/portal/Soc_Gum/PhVSTS/2012_2/12tivsds.pdf</fullTextUrl>
<keywords lang="ENG">
<keyword>subconscious</keyword>
<keyword>defence</keyword>
<keyword>role</keyword>
<keyword>conflict</keyword>
<keyword>self-appraisal</keyword>
</keywords>
</record>
<record>
..................
</record>
</records>



file.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">
<records>
<xsl:apply-templates select="//record"/>
</records>
</xsl:template>

<xsl:template match="record">
<record>
<xsl:copy-of select="language"/>
<xsl:copy-of select="publisher"/>
<xsl:copy-of select="journalTitle"/>
<xsl:copy-of select="issn"/>
<xsl:copy-of select="publicationDate"/>
<xsl:copy-of select="volume"/>
<xsl:copy-of select="startPage"/>
<xsl:copy-of select="endPage"/>
<xsl:copy-of select="documentType"/>

<!-- далее не получается -->
<xsl:element name="title">
<xsl:attribute name="lang">
<xsl:value-of select="@lang" />
</xsl:attribute>
<xsl:copy-of select="title[@lang='eng']" />
</xsl:element>

<xsl:copy-of select="authors"/>
<xsl:copy-of select="affiliationsList"/>
<xsl:copy-of select="abstract"/>
<xsl:copy-of select="fullTextUrl"/>
<xsl:copy-of select="keywords"/>

</record>
</xsl:template>

</xsl:stylesheet>
...
Рейтинг: 0 / 0
03.05.2012, 22:56
    #37781295
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950, Очень сложно разобраться в том, что Вы пишете. Оформляйте код тегом [src]
http://www.sql.ru/faq/faq_topic.aspx?fid=202
...
Рейтинг: 0 / 0
04.05.2012, 09:20
    #37781530
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ спасибо за оперативный ответ. Просьба перезвонить мне - тел. в Харькове 755-73-58 (всегда на связи -это тел. CDMA), т.к. мне, как новичку, сложно изложить задачу в грамотном и привычном для Вас и Ваших коллег алгоритме:
общая задача: расположить имеющиеся данные 1.xml в порядке, представленном в 2.xml с некоторыми изменениями и добавлениями.


1.xml

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='file.xsl'?>
<records>
	<record>
		<language>rus</language>
		<publisher>Kharkov Regional Branch of the National Olympic Committee of Ukraine </publisher>
		<journalTitle> Fiziceskoe vospitanie studentov</journalTitle>
		<issn>20755279</issn>
		<publicationDate>2012-04-29</publicationDate>
		<volume>2</volume>
		<documentType>article</documentType>
		<startPage>100</startPage>
		<endPage>103</endPage>
		<authors>
			<author>
				<affiliationId>1</affiliationId>
				<name>Tolkunova I.V.</name>
				<email>Olya@mail.ru<;/email>
				<affiliationName>Kharkov National University</affiliationName>
			</author>
			<author>
				<affiliationId>2</affiliationId>
				<name>Krasnitskaya O.V.</name>
				<email>yui@ukr.net<;/email>
				<affiliationName>Kharkov National Aerospace University</affiliationName>
			</author>
			<author>
				<affiliationId>3</affiliationId>
				<name>Golets A.V.</name>
				<email>asfg@gmai.com<;/email>
				<affiliationName>National University of Physical Education and Sport of Ukraine</affiliationName>
			</author>
		</authors>
		<affiliationsList>
			<affiliationName affiliationId="1">University</affiliationName>
		</affiliationsList>
		<title lang="ENG">Subconscious defence for sportsmen</title>
		<abstract lang="ENG">The questions of necessity of study of reasons of subconscious defence of men and women of sportsmen and their gender distinctions are considered. It is marked that subconscious defence is one of major criteria of success of competition activity and achievement of high sporting result. </abstract>
		<keywords lang="ENG">
			<keyword>subconscious</keyword>
			<keyword>defence</keyword>
			<keyword>role</keyword>
			<keyword>conflict</keyword>
			<keyword>self-appraisal</keyword>
		</keywords>
		<fullTextUrl>12tivsds.pdf</fullTextUrl>
	</record>
	<record>
			.................	
	</record>		
</records>


2.xml
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
<?xml version="1.0" encoding="UTF-8"?>
<records>
	<record>
		<language>rus</language>
		<publisher>Kharkov Regional Branch of the National Olympic Committee of Ukraine </publisher>
		<journalTitle> Fiziceskoe vospitanie studentov</journalTitle>
		<issn>20755279</issn>
		<publicationDate>2012-04-29</publicationDate>
		<volume>2</volume>
		<startPage>100</startPage>
		<endPage>103</endPage>
		<documentType>article</documentType>
		<title language="eng">Subconscious defence for sportsmen</title>
		<authors>
			<author>
				<name>Tolkunova I.V.</name>
				<email>Olya@mail.ru<;/email>
				<affiliationId>1</affiliationId>
			</author>
			<author>
				<name>Krasnitskaya O.V.</name>
				<email>yui@ukr.net<;/email>
				<affiliationId>2</affiliationId>
			</author>			
			<author>
				<name>Golets A.V.</name>
				<email>asfg@gmai.com<;/email>
				<affiliationId>3</affiliationId>
			</author>		
		</authors>
		<affiliationsList>
			<affiliationName affiliationId="1">Kharkov National University</affiliationName>
			<affiliationName affiliationId="2">Kharkov National Aerospace University</affiliationName>
			<affiliationName affiliationId="3">National University of Physical Education and Sport of Ukraine</affiliationName>
		</affiliationsList>
		<abstract language="eng">The questions of necessity of study of reasons of subconscious defence of men and women of sportsmen and their gender distinctions are considered. It is marked that subconscious defence is one of major criteria of success of competition activity and achievement of high sporting result. </abstract>
		<fullTextUrl format="pdf">http://nbuv.gov.ua/portal/Soc_Gum/PhVSTS/2012_2/12tivsds.pdf</fullTextUrl>
		<keywords language="eng">
			<keyword>subconscious</keyword>
			<keyword>defence</keyword>
			<keyword>role</keyword>
			<keyword>conflict</keyword>
			<keyword>self-appraisal</keyword>
		</keywords>
	</record>
	<record>
	..................
	</record>
</records>



file.xsl
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:template match="/">
		<records>
			<xsl:apply-templates select="//record"/>
		</records>
	</xsl:template>

	<xsl:template match="record">
		<record>
			<xsl:copy-of select="language"/>
			<xsl:copy-of select="publisher"/>
			<xsl:copy-of select="journalTitle"/>
			<xsl:copy-of select="issn"/>
			<xsl:copy-of select="publicationDate"/>
			<xsl:copy-of select="volume"/>
			<xsl:copy-of select="startPage"/>
			<xsl:copy-of select="endPage"/>
			<xsl:copy-of select="documentType"/>

			<!-- далее не получается   -->     
			<xsl:element name="title">
				<xsl:attribute name="lang">
					<xsl:value-of select="@lang" />
				</xsl:attribute>
				<xsl:copy-of select="title[@lang='eng']" />
			</xsl:element>

			<xsl:copy-of select="authors"/> 
			<xsl:copy-of select="affiliationsList"/>
			<xsl:copy-of select="abstract"/>
			<xsl:copy-of select="fullTextUrl"/>
			<xsl:copy-of select="keywords"/>

		</record>
	</xsl:template>

</xsl:stylesheet>
...
Рейтинг: 0 / 0
04.05.2012, 13:05
    #37781954
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950Просьба перезвонить мне -Поверьте мне - по телефону объяснить будет еще сложнее

А задача решается просто.
1) Переопределяется шаблон по умолчанию
Код: xml
1.
2.
3.
4.
5.
<xsl:template match="*">
  <xsl:element name="{name(.)}">
    </xsl:value-of select="."/>
  </xsl:element>
</xsl:template>


2) Перед ним определяются шаблоны для тех элементов детей, которых, необходимо подвигать.
Код: xml
1.
2.
3.
4.
5.
6.
7.
<xsl:template match="author">
  <xsl:element name="{name(.)}">
    </xsl:apply-templates select="name"/>
    </xsl:apply-templates select="email"/>
    </xsl:apply-templates select="affiliationName"/>
  </xsl:element>
</xsl:template>


Все.

Т.к. у Вас еще идет замена атрибутов, то делаем так
1) Переопределяем шаблоны для нужных атрибутов
Код: xml
1.
2.
3.
4.
5.
<xsl:template match="@lang">
  <xsl:attribute name="language">
    <xsl:value-of select="translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
  </xsl:attribute>
</xsl:template>


2) Определяем шаблон по умолчанию для атрибутов
Код: xml
1.
2.
3.
4.
5.
<xsl:template match="@*">
  <xsl:attribute name="{name(.)}">
    <xsl:value-of select="."/>
  </xsl:attribute>
</xsl:template>


3) Переопределяем шаблон по умолчанию для элементов
Код: xml
1.
2.
3.
4.
5.
6.
<xsl:template match="*">
  <xsl:element name="{name(.)}">
    <xsl:apply-templates select="@*"/>
    </xsl:value-of select="."/>
  </xsl:element>
</xsl:template>



Для модификации определенных элементов определяем шаблоны для этих элементов
Код: xml
1.
2.
3.
4.
5.
<xsl:template match="fullTextUrl">
  <fullTextUrl format="pdf">
    <xsl:value-of select="concat('http://nbuv.gov.ua/.../2012_2/', .)"/>
  <fullTextUrl>
</xsl:template>



В итоге у Вас должно получиться, что-то типа такого
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="record">
    <xsl:element name="{name(.)}">
      .................
    </xsl:element>
  </xsl:template>

  <xsl:template match="author">
    <xsl:element name="{name(.)}">
      </xsl:apply-templates select="name"/>
      </xsl:apply-templates select="email"/>
      </xsl:apply-templates select="affiliationName"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="fullTextUrl">
    <fullTextUrl format="pdf">
      <xsl:value-of select="concat('http://nbuv.gov.ua/.../2012_2/', .)"/>
    <fullTextUrl>
  </xsl:template>

  <xsl:template match="@lang">
    <xsl:attribute name="language">
      <xsl:value-of select="translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:attribute name="{name(.)}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>

  <xsl:template match="*">
    <xsl:element name="{name(.)}">
      <xsl:apply-templates select="@*"/>
      </xsl:value-of select="."/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

...
Рейтинг: 0 / 0
04.05.2012, 14:03
    #37782047
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ , спасибо. Воспользуюсь Вашими рекомендациями. Имею еще подобные задачи, связанные с xml. Если Вы располагаете немного свободным временем - может попробуете их решить. Отправляйте короткое SMS с http://www.cdma.ua/sms/ на мой телефон.
...
Рейтинг: 0 / 0
04.05.2012, 14:27
    #37782081
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950Имею еще подобные задачи, связанные с xml. Если Вы располагаете немного свободным временем - может попробуете их решить.Если Вы готовы оплатить мою работу, то вот моя почта anton_83 <at> mail <dot> ru
...
Рейтинг: 0 / 0
04.05.2012, 17:27
    #37782539
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_моя почтаЧто-то я совсем заработался. Вот правильный ящик anton_83 <at> list <dot> ru
...
Рейтинг: 0 / 0
26.05.2012, 10:36
    #37812731
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ спасибо. Но не все получается.
Имеем фрагмент файл authors.xml
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
<?xml version="1.0" encoding="UTF-8"?>
<records>
	<record>
................
		<authors>
			<author num="1">
				<name>Adamczyk Jakub Grzegorz</name>
				<email>jadamczyk@edu.pl<;/email>
				<affiliationName>Jozef Pilsudski Academy</affiliationName>
			</author>
			<author num="2">
				<name>Boguszewski Dariusz</name>
				<email>mczyk@wum.edu.pl<;/email>
				<affiliationName>Medical University of Warsaw</affiliationName>
			</author>
			<author num="3">
				<name>Siewierski Marcin</name>
				<email>damc@wum.edu.pl<;/email>
				<affiliationName>Academy of Physical Education </affiliationName>
			</author>
		</authors>
		<fullTextUrl>12bafeeu.pdf</fullTextUrl>	
.................	
	</record>
</records>


Необходимо для <author num="1">
изменить
Код: xml
1.
<affiliationName>Jozef Pilsudski Academy</affiliationName>


на следующее
Код: xml
1.
<affiliationName affiliationId="1">Jozef Pilsudski Academy</affiliationName>


и полученное перенести в
Код: xml
1.
2.
3.
 <affiliationsList>
	<affiliationName affiliationId="1">Jozef Pilsudski Academy</affiliationName>
</affiliationsList>


также добавить:
Код: xml
1.
<affiliationId>1</affiliationId>


Аналогично для num="2", num="3" и т.д.
Также не удается получить вместо:
Код: xml
1.
<fullTextUrl>12bafeeu.pdf</fullTextUrl>


следующее (сделал по Вашей рекомендации, но указывает на ошибку):
Код: xml
1.
<fullTextUrl format="pdf">http://nbuv.gov.ua/portal/Soc_Gum/PhVSTS/2011_6/12bafeeu.pdf</fullTextUrl>


делаю так:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>

 <xsl:template match="record">
<xsl:copy>
<xsl:apply-templates select="authors"/>
<affiliationsList>
<xsl:apply-templates select="authors/author/affiliationName"/>
</affiliationsList>
<xsl:apply-templates select="fullTextUrl"/>
</xsl:copy>
</xsl:template> 

<xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
  
  <xsl:template match="@num">
        <affiliationId>
            <xsl:value-of select="."/>
        </affiliationId>
    </xsl:template>

        <xsl:template match="affiliationName">
        <affiliationName affiliationId="">
            <xsl:value-of select="."/>
        </affiliationName>
    </xsl:template>    

 <xsl:template match="fullTextUrl">
    <fullTextUrl format="pdf">
      <xsl:value-of select="concat('http://nbuv.gov.ua/portal/Soc_Gum/PhVSTS/2012_2/', .)"/>
    <fullTextUrl>
  </xsl:template>

</xsl:stylesheet>


получаю:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
<?xml version="1.0" encoding="UTF-8"?>

<records>
	<record>
		<authors>
			<author>
				<affiliationId>1</affiliationId>
				<name>Adamczyk Jakub Grzegorz</name>
				<email>jadamczyk@edu.pl<;/email>
				<affiliationName affiliationId="">Jozef Pilsudski Academy</affiliationName>
			</author>
			<author>
				<affiliationId>2</affiliationId>
				<name>Boguszewski Dariusz</name>
				<email>mczyk@wum.edu.pl<;/email>
				<affiliationName affiliationId="">Medical University of Warsaw</affiliationName>
			</author>
			<author>
				<affiliationId>3</affiliationId>
				<name>Siewierski Marcin</name>
				<email>damc@wum.edu.pl<;/email>
				<affiliationName affiliationId="">Academy of Physical Education </affiliationName>
			</author>
		</authors>
		<affiliationsList>
			<affiliationName affiliationId="">Jozef Pilsudski Academy</affiliationName>
			<affiliationName affiliationId="">Medical University of Warsaw</affiliationName>
			<affiliationName affiliationId="">Academy of Physical Education </affiliationName>
		</affiliationsList>
		<fullTextUrl>12bafeeu.pdf</fullTextUrl>
	</record>
</records>


необходимо получить:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
<?xml version="1.0" encoding="UTF-8"?>

<records>
	<record>
		<authors>
			<author>
				<name>Adamczyk Jakub Grzegorz</name>
				<email>jadamczyk@edu.pl<;/email>
				<affiliationId>1</affiliationId>
			</author>
			<author>
				<name>Boguszewski Dariusz</name>
				<email>mczyk@wum.edu.pl<;/email>
				<affiliationId>2</affiliationId>
			</author>
			<author>
				<name>Siewierski Marcin</name>
				<email>damc@wum.edu.pl<;/email>
				<affiliationId>3</affiliationId>
			</author>
		</authors>
		<affiliationsList>
			<affiliationName affiliationId="1">Jozef Pilsudski Academy</affiliationName>
			<affiliationName affiliationId="2">Medical University of Warsaw</affiliationName>
			<affiliationName affiliationId="3">Academy of Physical Education </affiliationName>
		</affiliationsList>
		<fullTextUrl format="pdf">http://nbuv.gov.ua/portal/Soc_Gum/PhVSTS/2011_6/12bafeeu.pdf</fullTextUrl>
	</record>
</records>
...
Рейтинг: 0 / 0
28.05.2012, 13:12
    #37814366
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950делаю так:
1) Добавить такой шаблон
Код: xml
1.
2.
3.
4.
5.
6.
7.
<xsl:template match="author">
  <author>
    <xsl:apply-templates select="name"/>
    <xsl:apply-templates select="email"/>
    <xsl:apply-templates select="@num"/>
  </author>
</xsl:template> 



2) Изменить шаблон
Код: xml
1.
2.
3.
4.
5.
<xsl:template match="affiliationName">
  <affiliationName affiliationId="{../@num}">
    <xsl:value-of select="."/>
  </affiliationName>
</xsl:template>    


3) Исправить ошибку
Код: xml
1.
2.
3.
4.
5.
 <xsl:template match="fullTextUrl">
  <fullTextUrl format="pdf">
    <xsl:value-of select="concat('http://nbuv.gov.ua/portal/Soc_Gum/PhVSTS/2012_2/', .)"/>
  </fullTextUrl>
</xsl:template>



4) Шаблон
Код: xml
1.
<xsl:template match="@* | node()">

сделать самым последним

Все
...
Рейтинг: 0 / 0
28.05.2012, 22:30
    #37815382
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ СПАСИБО!!!!! Задача решена.
В образовательном плане также помог ресурс:
http://www.java2s.com/Tutorial/XML/0100__XSLT-stylesheet/Catalog0100__XSLT-stylesheet.htm
...
Рейтинг: 0 / 0
02.06.2012, 00:14
    #37822273
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Попробовал по аналогии как и для <author num="1">
Код: xml
1.
2.
3.
4.
5.
<author num="1">
	<name>Adamczyk Jakub Grzegorz</name>
	<email>jadamczyk@edu.pl<;/email>
	<affiliationName>Jozef Pilsudski Academy</affiliationName>
</author>



выполнить преобразование для случая <author locale="eng">
Код: xml
1.
2.
3.
4.
5.
6.
7.
<author locale="eng">
	<lastname>Adashevskiy</lastname>
	<firstname>V.M.</firstname>
	<email>adashevsky@ukr.net<;/email>
	<affiliation>NTU</affiliation>
	<country>Frunze str. 21, Kharkov, 61002, Ukraine</country>
</author>


необходимо получить
Код: xml
1.
2.
3.
4.
5.
6.
7.
<author>
	<firstname>V.M.</firstname>
	<lastname>Adashevskiy</lastname>
	<email>adashevsky@ukr.net<;/email>
	<affiliation locale="en_US">NTU</affiliation>
	<country>Ukraine</country>
</author>


не могу получить <affiliation locale="en_US">NTU</affiliation> и <country>Ukraine</country>
...
Рейтинг: 0 / 0
02.06.2012, 00:27
    #37822278
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950не могу получить <affiliation locale="en_US">NTU</affiliation>Так все один в один как и с атрибутом num. Или я не понял в чем проблема
Sergii1950и <country>Ukraine</country>substring-before(), substrng-after()?
...
Рейтинг: 0 / 0
02.06.2012, 23:11
    #37822905
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ , спасибо. Моя невнимательность - т.к. в файле имеются и др. подобные значения (abstract lang="ENG"...), то указал полный путь. Задача решена:
Код: xml
1.
<xsl:template match="articles/article/authors/individInfo[@locale]">


По рекомендации - substring-before(), substrng-after()? - сразу не получилось, буду пробовать еще, т.к. в файле имеются и другие названия (Russian, USA, IRAN, POLAND и др.)
Еще одна подобная задача:
Код: xml
1.
2.
3.
4.
5.
6.
7.
<indexing locale="eng">
	<subject>walking</subject>
	<subject>health</subject>
	<subject>age</subject>
	<subject>stick</subject>
	<subject>biomechanics</subject>
</indexing>


Необходимо получить
Код: xml
1.
2.
3.
<indexing> 
<subject locale="eng">walking; health; age; stick; biomechanics</subject>
</indexing> 


делаю так:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
<xsl:template match="indexing">
<indexing>    
	<subject locale="{../@locale}">
		<xsl:value-of
      select="concat(subject[1], '; ',subject[2], '; ',subject[3], '; ',subject[4], '; ',subject[5],'','')" />
	</subject>   
</indexing>  
  </xsl:template>


получаю с ошибкой - вместо subject locale="eng" имеем
Код: xml
1.
2.
3.
<indexing>
	<subject locale="">walking; health; age; stick; biomechanics</subject>
</indexing>


как поступить, если таких слов как subject будет встречаться не 5, а разное количество, но не более 10?
Также как заменить "eng" на "en_US"
...
Рейтинг: 0 / 0
03.06.2012, 19:32
    #37823346
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950По рекомендации - substring-before(), substrng-after()? - сразу не получилось, буду пробовать еще, т.к. в файле имеются и другие названия (Russian, USA, IRAN, POLAND и др.)Вот я и говорю, что перед трансфомацией нужно формализовать правила по, которым, будет подставляться название
Sergii1950получаю с ошибкой - вместо subject locale="eng" имеемА нужно так
Код: xml
1.
<subject locale="{@locale}">

нужно контролировать текущий контестный узел
Sergii1950как поступить, если таких слов как subject будет встречаться не 5, а разное количество
Код: xml
1.
2.
3.
4.
<xsl:template match="subject">
  <xsl:value-of select="."/>
  <xsl:if test=". != last()">; </xsl:if>
</xsl:template>


Sergii1950Также как заменить "eng" на "en_US"<xsl:if>, <xsl:choose>
...
Рейтинг: 0 / 0
07.06.2012, 08:30
    #37828763
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ , спасибо. Не получилось заменить "eng" на "en_US", "rus" на "ru_RU", "ukr" на "uk_UA", а также рекомендации использовать substring-before(), substrng-after(). Поэтому эти 2 позиции сделал в обычном блокноте через "Заменить". Если имеете время и возможность, то приведите решение и тем не менее все равно большое спасибо за уроки и помощь. В принципе задача решена. С уважением, Sergii1950.
...
Рейтинг: 0 / 0
07.06.2012, 11:44
    #37829093
mage.lan
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950,

вместо
Код: xml
1.
<subject locale="{@locale}">...</subject>


будет
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
<subject>
  <xsl:attribute name="locale">
    <xsl:choose>
      <xsl:when test="@locale = 'rus'>ru_RU</xsl:when>
      <xsl:when test="@locale = 'eng'>en_US</xsl:when>
      <xsl:when test="@locale = 'ukr'>uk_UA</xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="@locale"/>
      </xsl:otherwise>
  </xsl:attribute>
  ...
</subject>
...
Рейтинг: 0 / 0
09.01.2013, 08:08
    #38102809
Sergii1950
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
mage.lan спасибо. не заменяет: "eng" на "en_US"; "rus" на "ru_RU"; "ukr" на "uk_UA". Пример немного подправил. Но, в чем ошибка?, Файл xml:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
<?xml version="1.0" encoding="UTF-8"?>
<articles>
	<article>
		<title locale="eng">Determination </title>
		<title locale="rus">ОПРЕДЕЛЕНИЕ </title>
		<title locale="ukr">Визначення </title>
		<abstract locale="eng">Directions </abstract>
		<abstract locale="rus">Рассмотрены</abstract>
		<abstract locale="ukr">Розглянуто</abstract>
		<indexing>
			<subject locale="eng">educational</subject>
			<subject locale="rus">учебный</subject>
			<subject locale="ukr">учбовий</subject>
		</indexing>
		<author>
			<affiliation locale="eng">Luhansk</affiliation>
		</author>
		<galley locale="eng">
			<label>PDF</label>
		</galley>
	</article>
</articles>


файл xsl
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>

<xsl:template match="article">
  <article>
    <xsl:apply-templates select="title"/>
     <xsl:apply-templates select="abstract"/>
    <xsl:apply-templates select="keywords"/>     
    <xsl:apply-templates select="author"/>  
    <xsl:apply-templates select="pages"/>          
    <xsl:apply-templates select="date_published"/>
    <xsl:apply-templates select="galley"/> 
    
  <xsl:attribute name="locale">
    <xsl:choose>
      <xsl:when test="@locale = 'rus'">ru_RU</xsl:when>
      <xsl:when test="@locale = 'eng'">en_US</xsl:when>
      <xsl:when test="@locale = 'ukr'">uk_UA</xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="@locale"/>
      </xsl:otherwise>
      </xsl:choose>
  </xsl:attribute>    
    </article>
</xsl:template> 

<xsl:template match="@* | node()">
</xsl:template>     
<xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>


В итоге файл xml остается без изменений
...
Рейтинг: 0 / 0
09.01.2013, 18:08
    #38103911
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
Sergii1950Но, в чем ошибка?,В исходном XML в теге article нет атрибута locale
...
Рейтинг: 0 / 0
Период между сообщениями больше года.
12.04.2017, 09:50
    #39437034
flashSQL
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_ Вот правильный ящик anton_83 <at> list <dot> ru
Здравствуйте, _Vasilisk_
А как можно с Вами связаться на настоящее время?
Спасибо
...
Рейтинг: 0 / 0
12.04.2017, 14:39
    #39437351
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
flashSQLА как можно с Вами связаться на настоящее время?По какому вопросу?
...
Рейтинг: 0 / 0
12.04.2017, 14:49
    #39437365
flashSQL
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
_Vasilisk_По какому вопросу?
Коммерческому, связанному с XML
...
Рейтинг: 0 / 0
13.04.2017, 15:44
    #39438030
_Vasilisk_
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Не получается полностью создать xsl. Прошу помощи
flashSQL,

anton dot tramp at gmail dot com
...
Рейтинг: 0 / 0
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Не получается полностью создать xsl. Прошу помощи / 22 сообщений из 22, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]