단계별 XSLT 명명 템플릿 가져오기
동인지에 예정된 내용의 일부분을 수록하다.이것은 match에서 순서대로 변환할 수 있는 원본 문서가 없는named 템플릿을 가정합니다.하지만
<xsl:source-document>
등에도 적용할 수 있다.먼저 생략된 HTML(X)named template에서 이럴 때도 괜찮아요.
필요한 요소를 열거하다.
<main>
...
<article class="card">
<img class="img card-img img-fluid" decording="async"
src="hoge.jpg" alt="card image"/>
<div class="card-body">
<h1 class="card-title">TITLE</h1>
<p class="card-text"><strong>This</strong> card is ...</p>
</div>
</article>
...
</main>
중복서사attribute
를 묶는다.기본적으로 한 요소xsl:use-attribute-sets
에 적힌 attribute-set
명을 관리에서 하나로 선정했다.<img>
의@src
와@alt
는 개별적인 값이기 때문에 여기에 합치지 않습니다.
<xsl:attribute-set name="atts.card">
<xsl:attribute name="class">card</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="atts.card.img">
<xsl:attribute name="class">img card-img img-fluid</xsl:attribute>
<xsl:attribute name="decording">async</xsl:attribute>
</xsl:attribute-set>
...
<xsl:template ...>
<main>
...
<article xsl:use-attribute-sets="atts.card">
<img xsl:use-attribute-sets="atts.card.img" src="hoge.jpg" alt="card image"/>
<div xsl:use-attribute-sets="atts.card.body">
<h1 xsl:use-attribute-sets="atts.card.body.title">TITLE</h1>
<p xsl:use-attribute-sets="atts.card.body.text"><strong>This</strong> card is ...</p>
</div>
</article>
...
</main>
</xsl:template>
<xsl:template>
로 묶어 대원의 구조에서 떼어낸다.
<xsl:template name="card">
<article xsl:use-attribute-sets="atts.card">
<img xsl:use-attribute-sets="atts.card.img" src="hoge.jpg" alt="card image"/>
<div xsl:use-attribute-sets="atts.card.body">
<h1 xsl:use-attribute-sets="atts.card.body.title">TITLE</h1>
<p xsl:use-attribute-sets="atts.card.body.text"><strong>This</strong> card is ...</p>
</div>
</article>
</xsl:template>
<xsl:template ...>
...
<main>
...
<xsl:call-template name="card">
</xsl:call-template>
...
</main>
</xsl:template>
<xsl:template name="card">
에서 개별 내용을 기술한 부분을 추출하여 매개 변수화한다.대체로 괜찮다.그리고 매개 변수화된 내용을 대원으로 되돌려줍니다.<xsl:value-of>
는 텍스트 추출로 하고 <xsl:copy-of>
는 구조를 유지할 수 있다.<xsl:template name="card">
<xsl:param name="card.img" as="item()" required="yes"/>
<xsl:param name="card.body" as="item()" required="yes"/>
<article xsl:use-attribute-sets="atts.card">
<xsl:copy-of select="$card.img" />
<div xsl:use-attribute-sets="atts.card.body">
<xsl:copy-of select="$card.body"/>
</div>
</article>
</xsl:template>
<xsl:template ...>
<main>
...
<xsl:call-template name="card">
<xsl:with-param name="card.img" >
<img xsl:use-attribute-sets="atts.card.img" src="hoge.jpg" alt="card image"/>
</xsl:with-param>
<xsl:with-param name="card.body">
<h1 xsl:use-attribute-sets="atts.card.body.title">TITLE</h1>
<p xsl:use-attribute-sets="atts.card.body.text"><strong>This</strong> card is ...</p>
</xsl:with-param>
</xsl:call-template>
...
</main>
</xsl:template>
이하 역시 진행한다.XML 구조로 된 레이크의 외관 때문에 섀도우 돔 등으로 쉽게 이동할 수 있을지도 모른다.정말?
Reference
이 문제에 관하여(단계별 XSLT 명명 템플릿 가져오기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/hidaruma/articles/34df11f199764c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)