2010-08-13 1 views
6

많은 수의 출력 형식을 제공하기 위해 약 12 ​​개의 XSLT 파일을 사용하고 있습니다. 현재 사용자는 파일 형식의 확장자를 알 필요가 있습니다. RTF, HTML, TXT.XSLT 관리 - 출력 및 매개 변수를 위해 스타일 시트에 메타 데이터 첨부하기

더 많은 옵션을 허용하기 위해 매개 변수를 사용하고 싶습니다. 메타 데이터를 XSL 파일에 포함 할 수 있다면 파일을 스캔하여 세부 정보를 가져올 수 있습니다.

다음은 내가 생각하고있는 것입니다. 이 예제에서 프로그램은 필수 정보에 대한 주석을 구문 분석해야합니다.

<?xml version="1.0" encoding="UTF-8"?> 
<!-- Title: Export to Rich Text Format --> 
<!-- Description: This Stylesheet converts to a Rich Text Format format which may be used in a word processor such as Word --> 
<!-- FileFormat: RTF --> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
<xsl:param name="CompanyName"/> <!-- Format:String, Description: Company name to be inserted in the footer --> 
<xsl:param name="DateDue"/> <!-- Format:Date-yyyy-mm-dd, Description: Date Due --> 
<xsl:param name="IncludePicture">true</xsl:param><!-- Format:Boolean, Description: Do you want to include a graphical representation? --> 
    <xsl:template match="/"> 
    <!-- Stuff --> 
    </xsl:template> 
</xsl:stylesheet> 

표준이 있습니까? 두 개 이상의 정육점을 사용해야합니까 (XML 스키마가 깔끔한 더블린 코어)?

P. 이 프로젝트가 적용되는 프로젝트는 Argumentative입니다.

+0

아주 좋은 질문 (+1). XSLT에서 메타 데이터를 표현하는 방법에 대한 더 나은 해결책은 내 대답을 참조하십시오. –

답변

6

다음은 내가 생각하고있는 것입니다. 이 예제에서 프로그램은 정보에 대한 설명을 구문 분석해야합니다.

은 댓글 내에 메타 데이터를 코딩해야합니다.

일반 XML 마크 업을 사용하여 XSLT 스타일 시트의 일부로 메타 데이터를 지정할 수 있습니다. 구조와 의미가 풍부해야하며이 필요합니다. 여기

을 수행하는 방법의 예입니다 : 이러한 변화가 어떤 XML 문서 (사용되지 않음), 결과가이다에 적용

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:meta="my:meta"> 
<xsl:output method="text"/> 

<meta:metadata> 
    <title>Title: Export to Rich Text Format </title> 
    <description> 
    This Stylesheet converts to a Rich Text 
    Format format which may be used in a word processor 
    such as Word 
    </description> 
    <fileFormat>RTF</fileFormat> 
    <parameters> 
    <parameter name="CompanyName" format="xs:string" 
     Description="Company name to be inserted in the footer"/> 

    <parameter name="DateDue" format="xs:date" 
     Description="Date Due"/> 

    <parameter name="IncludePicture" format="xs:boolean" 
     Description="Do you want to include a graphical representation?"/> 
    </parameters> 
</meta:metadata> 

<xsl:param name="CompanyName"/> 
<xsl:param name="DateDue"/> 
<xsl:param name="IncludePicture" select="true"/> 

<xsl:variable name="vMetadata" select= 
     "document('')/*/meta:metadata"/> 

<xsl:template match="/"> 
    This is a demo how we can access and use the metadats. 

    Metadata --> Description: 

    "<xsl:copy-of select="$vMetadata/description"/>" 
</xsl:template> 
</xsl:stylesheet> 

:

This is a demo how we can access and use the metadats. 

    Metadata --> Description: 

    " 
    This Stylesheet converts to a Rich Text 
    Format format which may be used in a word processor 
    such as Word 
    " 

메모를 수행 :

  1. 네임 스페이스에있는 요소 (물론 네임 스페이스가 아닌 xsl 네임 스페이스)는 모든 xslt 스타일 시트의 전역 수준에서 지정할 수 있습니다.

  2. 이러한 요소는 xslt 함수 document()을 사용하여 액세스 할 수 있습니다.

+0

멋진 답변입니다. 나는 특히 내성적 인 "document ('')/*/meta : metadata"를 좋아했다. 많은 감사 –

+0

@ JohnHartley : 사실, 코드의 형식이 잘못되었다. –

관련 문제