2016-07-10 1 views
0

의 도움으로 하나의 XML을 사용하여 여러 XMLS을 만들고 난 다음 입력 XML이 :XSL 문제 : XSLT2.0

<?xml version="1.0" encoding="UTF-8"?> 
<class xmlns:xfa="soommmeee-tteexxxxtttttt"> 
    <students> 
     <id>A</id> 
     <name>jscvjab</name> 
     <description>zcm,ab</description> 
     <student> 
      <id>1</id> 
      <refObjectId>m9</refObjectId> 
      <subject> 
       <id>25</id> 
       <name>science</name> 
       <friend>popeye</friend> 
       <firstname> 
        <isDisplay>true</isDisplay> 
       </firstname> 
       <lastname> 
        <Detail> 
         <lastNameDetail> 
          <fragId>kullu</fragId> 
          <znjdvgsc>nSVCm</znjdvgsc> 
          <zmdcb>zmbvc</zmdcb> 
         </lastNameDetail> 
        </Detail> 
       </lastname> 
      </subject> 
     </student> 
     <student> 
      <id>2</id> 
      <refObjectId>m5</refObjectId> 
      <subject> 
       <id>92</id> 
       <name>commerce</name> 
       <friend>brutus</friend> 
       <firstname> 
        <textContent> 
         <Id>m9</Id> 
         <title xfa:contentType="text/html"> 
          <body>Title</body> 
         </title> 
         <text xfa:contentType="text/html"> 
          <body>Contents</body> 
         </text> 
         <Key>Slide</Key> 
        </textContent> 
        <textContent> 
         <Id>m95</Id> 
         <title xfa:contentType="text/html"> 
          <body>SubTitle</body> 
         </title> 
         <text xfa:contentType="text/html"> 
          <body>Jerry</body> 
         </text> 
         <Key>SubTitle</Key> 
        </textContent> 
        <isDisplay>false</isDisplay> 
       </firstname> 
       <lastname> 
        <Detail> 
         <lastNameDetail> 
          <fragId>zxZXVj</fragId> 
          <znjdvgsc>kjsdgfjkvnwsa</znjdvgsc> 
          <zmdcb>kadbvscjkna</zmdcb> 
         </lastNameDetail> 
        </Detail> 
       </lastname> 
      </subject> 
     </student> 
    </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> 
    <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으로 원하는 것은 그것이 XSLT2를 사용하여 여러 XMLS로 나누어받을 shoould이다를 .0 각 xml은 노드의 나머지 부분을 포함하여 각각 하나의 '학생'으로 구성되어야하며 친구에 따라 이름을 가져야합니다. 첫 번째 XSL 1. 뽀빠이해야 말 :

<?xml version="1.0" encoding="UTF-8"?> 
<class xmlns:xfa="soommmeee-tteexxxxtttttt"> 
    <students> 
     <id>A</id> 
     <name>jscvjab</name> 
     <description>zcm,ab</description> 
     <student> 
      <id>1</id> 
      <refObjectId>m9</refObjectId> 
      <subject> 
       <id>25</id> 
       <name>science</name> 
       <friend>popeye</friend> 
       <firstname> 
        <isDisplay>true</isDisplay> 
       </firstname> 
       <lastname> 
        <Detail> 
         <lastNameDetail> 
          <fragId>kullu</fragId> 
          <znjdvgsc>nSVCm</znjdvgsc> 
          <zmdcb>zmbvc</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> 

과 2 브루투스와 3 헤라클레스 등 ........ 이 문제에 도움을 주시기 바랍니다에 의해 다음과 같은 ..... 나는이 일의 차이를 만들 수 없습니다 .... 감사합니다

+0

그래서 무엇이 문제입니까? 'xsl : result-document' 사용은 쉬워야합니다. –

+0

@MartinHonnen 그래도 나는 그걸로는 할 수 없다 .... 나는 다른 학생이 학생 아래에 있고 그것을 그대로 나머지 데이터를 원하지만 모든 학생들을 위해 새로운 XML이 있어야한다 ..... 나는 샘플 출력을했다. 위 ..... 나는 정말로 그것을 할 수 없다. – NealGul

답변

0

이것은 당신을 시작할 것입니다.

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    exclude-result-prefixes="xs" 
    version="2.0"> 

    <xsl:template match="/"> 
     <xsl:apply-templates/> 
     <xsl:message select="'Done splitting the XML file.'"/> 
    </xsl:template> 

    <xsl:template match="student">      
     <xsl:variable 
      name="filename" 
      select="concat(count(preceding::student)+1,'.xml')"/> 

     <xsl:message select="concat('Writing ',$filename)"/> 

     <xsl:result-document 
      method="xml" 
      omit-xml-declaration="no" 
      encoding="UTF-8" 
      indent="yes" 
      href="{$filename}">    
      <xsl:copy-of select="."/>    
     </xsl:result-document>     
    </xsl:template> 

    <xsl:template match="text()"/> 

</xsl:stylesheet> 

파일 이름을 설정하는 것이 좋습니다. 각 파일 이름은 절대적으로 고유해야합니다. 브루투스라는 이름의 2 명의 학생과 같은 복제본이 있다면 변환을 중단합니다. xml에 고유 한 요소를 찾을 수 없어 번호 매겨진 파일을 만들기위한 대안으로 학생 수를 사용했습니다.

+0

이 하나가 작동하지 않는다. ... n 이해하기가 혼란스러워 ..... – NealGul