2016-09-08 2 views
0

의 일부 집합에 템플릿을 적용 나는 다음과 같은 입력 XML 문서가 : 내가 원하는XSL : 요소

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<book> 
<article> 
<section><title>DESCRIPTION</title> 
<p>The A380 is available with two types of turbofan engines, the 
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine 
Alliance GP7000 (A380-861 and −863F). Noise reduction was an important 
requirement in the A380 design, and particularly affects engine design.</para> 
<para>Landing gears<ul> 
<li><p>Nose Landing Gear</p> 
</li> 
<li><p>Wing Landing Gear (Bogie Type, 4 Wheels - 4 Braked)</p> 
</li> 
<li><p>Body Landing Gear (Bogie Type, 6 Wheels - 4 Braked)</p> 
</li> 
</ul></p> 
<section><title>Wing Landing Gear</title> 
<p>Each wing landing gear has a leg assembly and 
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator 
(BTA) and an oleo-pneumatic shock absorber.</p> 
</section><section><title>Body Landing Gear</title> 
<p>The two body landing gears have a six-wheel bogie 
beam and a leg assembly that includes an oleo- pneumatic shock absorber. 
A two-piece drag-stay assembly mechanically locks the leg in the extended 
position.</p> 
    <fig xml:id="HSXWB-A-79-11-11-00A01-000A-DTRENTXWB-A-00-00-00-01A01-022A-D-fig-0001" label="1"><title>Landing gear</title> 
     <image align="center" fileref="ICN-HSXWB-A-791111-H-F0302-00001-A-001-01"/></fig> 
</section></section></article><book> 

:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<book> 
<article> 
    <section><title>DESCRIPTION</title> 
<para>The A380 is available with two types of turbofan engines, the 
Rolls-Royce Trent 900 (variants A380-841, −842 and −843F) or the Engine 
Alliance GP7000 (A380-861 and −863F). Noise reduction was an important 
requirement in the A380 design, and particularly affects engine design.</para> 
<para>Landing gears<itemizedlist> 
<listitem><para>Nose Landing Gear</para> 
</listitem> 
<listitem><para>Wing Landing Gear (Bogie Type, 4 Wheels - 4 Braked)</para> 
</listitem> 
<listitem><para>Body Landing Gear (Bogie Type, 6 Wheels - 4 Braked)</para> 
</listitem> 
</itemizedlist></para> 
<section><title>Wing Landing Gear</title> 
<para>Each wing landing gear has a leg assembly and 
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator 
(BTA) and an oleo-pneumatic shock absorber.</para> 
</section><section><title>Body Landing Gear</title> 
<para>The two body landing gears have a six-wheel bogie 
beam and a leg assembly that includes an oleo- pneumatic shock absorber. 
A two-piece drag-stay assembly mechanically locks the leg in the extended 
position.</para> 
    <figure xml:id="HSXWB-A-79-11-11-00A01-000A-DTRENTXWB-A-00-00-00-01A01-022A-D-fig-0001" label="1"><title>Landing gear</title> 
     <mediaobject><imageobject><imagedata align="center" fileref="ICN-HSXWB-A-791111-H-F0302-00001-A-001-01"/></imageobject></mediaobject> 
     </figure> 
</section></section></article><book> 

내 목표는 유사한 변환 된 XML로 끝날하는 것입니다 title, para, list 및 figure에 대한 전체 집합에 대한 xslt를 작성합니다. 어떻게 모든 태그 집합을 커버하는 하나의 xsl : apply-template로 작성할 수 있습니까? 누군가

+0

"* 모든 태그 세트를 포함하도록 단일 xsl : apply-template을 작성하는 경우"원본의 계층 구조가 손실됩니다. 나열된 모든 노드는 형제가됩니다. 기대 한 결과물을 보면서, 그것은 당신이하고 싶은 것이 아닙니다. –

+0

Martin Honnen에게 감사드립니다. 나는 이것에 시도 할 것이다 –

답변

0

당신이 변환 및 기본 빌딩 블록으로 신원 변환 템플릿을 사용하려는 각 요소에 대한 템플릿을 작성 도와주세요 :

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> 

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

    <xsl:template match="itemizedlist"> 
     <ul> 
      <xsl:apply-templates/> 
     </ul> 
    </xsl:template> 

    <xsl:template match="listitem"> 
     <li> 
      <xsl:apply-templates/> 
     </li> 
    </xsl:template> 

    <xsl:template match="para"> 
     <p> 
      <xsl:apply-templates/> 
     </p> 
    </xsl:template> 
</xsl:transform> 

당신은 figure 자신을 더 템플릿을 추가 할 수 있습니다.

+0

안녕 마틴, 당신의 제공 한 부호는 잘 일했다. 임씨가이 작업을하는 동안 원하지 않는 네임 스페이스 속성이 다음과 같은 요소로 들어옴

. 어떻게 내가 xslt를 사용하여 이것을 제어 할 수 있습니다. . –

+0

'

'이 원치 않는 경우 XSLT의'xsl : transform' (또는'xsl : stylesheet') 루트 요소에'xmlns = "http://docbook.org/ns/docbook"'을 추가하십시오. –

+0

Martin 감사합니다. 이제 para 태그에서 제거되었습니다. 하지만

제거되지 않습니다. 이걸 도와주세요. –