Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Обработка двух файлов xml / 3 сообщений из 3, страница 1 из 1
10.04.2008, 09:26
    #35247084
Katya_83
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Обработка двух файлов xml
Помогите новичку. У меня есть два файла xml, которые в одном xsl должны обрабатываться. Первый файл обрабатывается нормально. Но после его обработки, должен обрабатываться второй. Пытаюсь его открыть функцией document, но у меня не получается обратиться к его узлам. Как это можно сделать?
...
Рейтинг: 0 / 0
10.04.2008, 09:50
    #35247147
SuSa
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Обработка двух файлов xml
1. include и import
2. пример искать в 1-й теме данного форума, в примерах
3. поиск по форуму, раза 2 уже точно на вопрос отвечали. ищи примерно по "2 xml"
...
Рейтинг: 0 / 0
14.04.2008, 18:02
    #35254329
ZakharovPA
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Обработка двух файлов xml
У меня похожая задача вот что откопал может поможет. это дока MSXML 4.0 SDK.
document Function
Provides a way to retrieve other XML resources from within the XSLT style sheet beyond the initial data provided by the input stream.

node-set document(object, node-set?)
Remarks
The document() function is versatile. Its effects vary, depending on the type and number of arguments that are used.

If only one argument is provided and that argument is a string, document() treats the string as a URL and retrieves the document as a set of nodes.
If only one argument is provided and that argument is a node set, then each node in that node set is treated as a URL and the function returns the union of all of the documents referenced.
If there are two arguments, the first argument can be either a string or a node set while the second argument must be a node set. The second argument, when supplied, serves to indicate the base URL to which the contents of the first argument are relative.
If an empty string is passed to the document() function, the result is the source XML of the XSLT document itself, unless the second argument is given (and is not null). In the latter case, the URL of the document is the base URL of the node contained in the second element.
Example
The following style sheet generates an XML document listing groups information "by values" explicitly from a source XML document listing the group information "by reference". Notice how the document() function is used to reference each group.

XML File (document.xml)

<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="document.xsl" ?>
<groups>
<groupRef href="http://localhost/hr/hrGroup.xml"/>
<groupRef href="myGroup.xml"/>
</groups>
Referenced XML File 1 (hrGroup.xml)

<?xml version='1.0'?>
<group name="hr">
<leader>mo</leader>
<member>bo</member>
<member>ko</member>
<member>lo</member>
</group>
Referenced XML File 2 (myGroup.xml)

<?xml version='1.0'?>
<group name="my">
<leader>john</leader>
<member>jane</member>
<member>jon</member>
<member>jan</member>
</group>
XSLT File (document.xsl)

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<groups>
<xsl:apply-templates select="//groupRef"/>
</groups>
</xsl:template>

<xsl:template match="groupRef">
<xsl:copy-of select="document(@href)//group"/>
</xsl:template>

</xsl:stylesheet>
Try It!

Copy the code samples above, and paste them into files on your local drive.
Save the files with the given names and extensions.
Create a new virtual directory, aliased as hr, under the default web site on your local machine. If you use a remote machine as the web server, change "localhost" to the host name of the web server in the value of the href attribute in the document.xml. If you use an existing virtual directory, change hr in the same href attribute value to whatever alias that directory has. Move the hrGroup.xml file to that directory.
Launch the XSLT transformation by opening it from Internet Explorer. To view the XSLT output, right click on the browser and select View XSL Output.
Output

The following is the processor output, with indentation added for clarity.

<?xml version="1.0"?>
<groups>
<group name="hr">
<leader>mo</leader>
<member>bo</member>
<member>ko</member>
<member>lo</member>
</group>
<group name="my">
<leader>john</leader>
<member>jane</member>
<member>jon</member>
<member>jan</member>
</group>
</grops>
...
Рейтинг: 0 / 0
Форумы / XML, XSL, XPath, XQuery [игнор отключен] [закрыт для гостей] / Обработка двух файлов xml / 3 сообщений из 3, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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