у меня есть следующий входной XML:XSL: создание выборочного XML, но с условием
<class xmlns:xfa="soommmeee-tteexxxxtttttt">
<students>
----------
-----------
----------
</students>
<students>
<id>B</id>
<name>jzvxcbhjnba</name>
<description>mjZSVxcj</description>
<student>
<id>3</id>
<refObjectId>m8</refObjectId>
<subject>
<id>91</id>
<name>humanities</name>
<friend>hercules</friend>
<firstname>
<textContent>
<Id>m954</Id>
<title xfa:contentType="text/html">
<body>Title</body>
</title>
<text xfa:contentType="text/html">
<body>Current</body>
</text>
<Key>Title</Key>
</textContent>
<textContent>
<Id>m9542</Id>
<title xfa:contentType="text/html">
<body>SubTitle</body>
</title>
<text xfa:contentType="text/html">
<body>Sr</body>
</text>
<Key>SubTitle</Key>
</textContent>
<isDisplay>false</isDisplay>
</firstname>
<lastname>
<Detail>
<lastNameDetail>
<fragId>aksbgdk</fragId>
<znjdvgsc>zsdbZXSBGCDSNXCJK</znjdvgsc>
<zmdcb>slzdhfksjfml</zmdcb>
</lastNameDetail>
</Detail>
</lastname>
</subject>
</student>
<student>
<id>3</id>
<refObjectId>m8</refObjectId>
<subject>
<id>91</id>
<name>humanities</name>
<friend>aladin</friend>
<firstname>
<textContent>
<Id>m954</Id>
<title xfa:contentType="text/html">
<body>Title</body>
</title>
<text xfa:contentType="text/html">
<body>Current</body>
</text>
<Key>Title</Key>
</textContent>
<textContent>
<Id>m9542</Id>
<title xfa:contentType="text/html">
<body>SubTitle</body>
</title>
<text xfa:contentType="text/html">
<body>Sr</body>
</text>
<Key>SubTitle</Key>
</textContent>
<isDisplay>false</isDisplay>
</firstname>
<lastname>
<Detail>
<lastNameDetail>
<fragId>aksbgdk</fragId>
<znjdvgsc>zsdbZXSBGCDSNXCJK</znjdvgsc>
<zmdcb>slzdhfksjfml</zmdcb>
</lastNameDetail>
</Detail>
</lastname>
</subject>
</student>
<student>
<id>3</id>
<refObjectId>m8</refObjectId>
<subject>
<id>91</id>
<name>humanities</name>
<friend>aladin</friend>
<firstname>
<textContent>
<Id>m954</Id>
<title xfa:contentType="text/html">
<body>Title</body>
</title>
<text xfa:contentType="text/html">
<body>Current</body>
</text>
<Key>Title</Key>
</textContent>
<textContent>
<Id>m9542</Id>
<title xfa:contentType="text/html">
<body>SubTitle</body>
</title>
<text xfa:contentType="text/html">
<body>Sr</body>
</text>
<Key>SubTitle</Key>
</textContent>
<isDisplay>false</isDisplay>
</firstname>
<lastname>
<Detail>
<lastNameDetail>
<fragId>aksbgdk</fragId>
<znjdvgsc>zsdbZXSBGCDSNXCJK</znjdvgsc>
<zmdcb>slzdhfksjfml</zmdcb>
</lastNameDetail>
</Detail>
</lastname>
</subject>
</student>
<student>
<id>4</id>
<refObjectId>m3</refObjectId>
<subject>
<id>75</id>
<name>PCM</name>
<friend>hercules</friend>
<firstname>
<textContent>
<Id>j4423</Id>
<title xfa:contentType="text/html">
<body>Title</body>
</title>
<text xfa:contentType="text/html">
<body>dfzxsdbjchA</body>
</text>
<Key>zdbgcfjkbna</Key>
</textContent>
<textContent>
<Id>m95</Id>
<title xfa:contentType="text/html">
<body>zdjbhfjkcda</body>
</title>
<text xfa:contentType="text/html">
<body>sdjkhzjk</body>
</text>
<Key>mzsdjkbjk</Key>
</textContent>
<isDisplay>true</isDisplay>
</firstname>
<lastname>
<Detail>
<lastNameDetail>
<fragId>sdbnfn</fragId>
<znjdvgsc>masdjkljk</znjdvgsc>
<zmdcb>msjkldbhfjkn</zmdcb>
</lastNameDetail>
</Detail>
</lastname>
</subject>
</student>
</students>
<students>
------------
--------------
</students>
<faculty>
<configuration>
<Type>Output</Type>
<Key>Font</Key>
<Value>10pt</Value>
</configuration>
<configuration>
<Type>Out</Type>
<Key>Text</Key>
<Value>127,127,127</Value>
</configuration>
<configuration>
<Type>put</Type>
<Key>Slide</Key>
<Value>18pt</Value>
</configuration>
<configuration>
<Type>utp</Type>
<Key>Slide</Key>
<Value>127</Value>
</configuration>
</faculty>
<Info />
<Dean>
<name>zcdfjkaqbkd</name>
</Dean>
</class>
Я хочу XSL, который вынимает целый раздел «студенты», включая подраздел «ученика», но только те, студент должен состоять из нового xml, который имеет своего друга как «геркулы». что «hercules» будет состоять в любом из студентов, он может быть более чем одним, а может быть, и в другом разделе «учеников»
Я не знаю, как это сделать .... я прошел через много примеров, но не в состоянии сделать это
сказать, что мой желаемый результат будет:
<?xml version="1.0" encoding="UTF-8"?>
<class xmlns:xfa="soommmeee-tteexxxxtttttt">
<students>
<id>B</id>
<name>jzvxcbhjnba</name>
<description>mjZSVxcj</description>
<student>
<id>3</id>
<refObjectId>m8</refObjectId>
<subject>
<id>91</id>
<name>humanities</name>
<friend>hercules</friend>
<firstname>
<textContent>
<Id>m954</Id>
<title xfa:contentType="text/html">
<body>Title</body>
</title>
<text xfa:contentType="text/html">
<body>Current</body>
</text>
<Key>Title</Key>
</textContent>
<textContent>
<Id>m9542</Id>
<title xfa:contentType="text/html">
<body>SubTitle</body>
</title>
<text xfa:contentType="text/html">
<body>Sr</body>
</text>
<Key>SubTitle</Key>
</textContent>
<isDisplay>false</isDisplay>
</firstname>
<lastname>
<Detail>
<lastNameDetail>
<fragId>aksbgdk</fragId>
<znjdvgsc>zsdbZXSBGCDSNXCJK</znjdvgsc>
<zmdcb>slzdhfksjfml</zmdcb>
</lastNameDetail>
</Detail>
</lastname>
</subject>
</student>
<student>
<id>4</id>
<refObjectId>m3</refObjectId>
<subject>
<id>75</id>
<name>PCM</name>
<friend>hercules</friend>
<firstname>
<textContent>
<Id>j4423</Id>
<title xfa:contentType="text/html">
<body>Title</body>
</title>
<text xfa:contentType="text/html">
<body>dfzxsdbjchA</body>
</text>
<Key>zdbgcfjkbna</Key>
</textContent>
<textContent>
<Id>m95</Id>
<title xfa:contentType="text/html">
<body>zdjbhfjkcda</body>
</title>
<text xfa:contentType="text/html">
<body>sdjkhzjk</body>
</text>
<Key>mzsdjkbjk</Key>
</textContent>
<isDisplay>true</isDisplay>
</firstname>
<lastname>
<Detail>
<lastNameDetail>
<fragId>sdbnfn</fragId>
<znjdvgsc>masdjkljk</znjdvgsc>
<zmdcb>msjkldbhfjkn</zmdcb>
</lastNameDetail>
</Detail>
</lastname>
</subject>
</student>
</students>
<faculty>
<configuration>
<Type>Output</Type>
<Key>Font</Key>
<Value>10pt</Value>
</configuration>
<configuration>
<Type>Out</Type>
<Key>Text</Key>
<Value>127,127,127</Value>
</configuration>
<configuration>
<Type>put</Type>
<Key>Slide</Key>
<Value>18pt</Value>
</configuration>
<configuration>
<Type>utp</Type>
<Key>Slide</Key>
<Value>127</Value>
</configuration>
</faculty>
<Info />
<Dean>
<name>zcdfjkaqbkd</name>
</Dean>
</class>
я думаю, что я ясно с идеей, и если есть что-то я могу сделать, чтобы объяснить больше, пожалуйста, комментарий ...... спасибо только
Ниже XSL я использую прямо сейчас:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="node()|@*" mode="Selected non-Selected">
<xsl:copy>
<xsl:apply-templates select="node()|@*" mode="#current" />
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:variable name="vResultSelected">
<xsl:apply-templates mode="Selected" />
</xsl:variable>
<xsl:for-each select="1 to 2">
<xsl:result-document
href="SectionOutput\{'Selected'[position()=current()]}.xml">
<xsl:copy-of select="($vResultSelected)[position() = current()]" />
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template mode="Selected"
match="students/*[not(*/friend = 'hercules')]" />
</xsl:stylesheet>
Это, по-видимому, очень простая проблема фильтрации XSLT. что ты уже испробовал? –
@MarcusRickert включил xslt, я использую ....пожалуйста, посмотрите – NealGul