⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsltproc.jam

📁 C++的一个好库。。。现在很流行
💻 JAM
字号:
#  Copyright (C) 2003 Doug Gregor. Permission to copy, use, modify,
#  sell and distribute this software is granted provided this
#  copyright notice appears in all copies. This software is provided
#  "as is" without express or implied warranty, and with no claim as
#  to its suitability for any purpose.

#  This module defines rules to apply an XSLT stylesheet to an XML file 
#  using the xsltproc driver, part of libxslt.
#
#  Note: except for 'init', this modules does not provide any rules
#  for end users. 

import feature ;
import regex ;
import sequence ;
import common ;

feature.feature xsl:param : : free ;
feature.feature xsl:path : : free ;
feature.feature catalog : : free ;

# Initialize xsltproc support. The parameters are:
#   xsltproc: The xsltproc executable
rule init ( xsltproc ? )
{
  if ! $(xsltproc)
  {
    xsltproc = [ modules.peek : XSLTPROC ] ;
  }

  if ! $(.initialized) 
  {
    $(.initialized) = true ;
    .xsltproc = $(xsltproc) ;
  }
}

rule compute-xslt-flags ( target : properties * )
{
  local flags ;
  # Translate <xsl:param> into command line flags.  
  for local param in [ feature.get-values <xsl:param> : $(properties) ]
  {
    local namevalue = [ regex.split $(param) "=" ] ;
    flags += --stringparam $(namevalue[1]) $(namevalue[2]) ;
  }
  # Translate <xsl:path>
  for local path in [ feature.get-values <xsl:path> : $(properties) ] 
  {
    flags += --path $(path:G=) ;
  }
        
  # Take care of implicit dependencies
  local other-deps ;
  for local dep in [ feature.get-values <implicit-dependency> : $(properties) ]
  {
    other-deps += [ $(dep:G=).creating-subvariant ] ;
  }

  local implicit-target-directories ;
  for local dep in [ sequence.unique $(other-deps) ]
  {
    implicit-target-directories += [ $(dep).all-target-directories ] ;
  }

  for local dir in $(implicit-target-directories)
  {
    flags += --path $(dir) ;
  }

  return $(flags) ;
}


local rule .xsltproc ( target : source stylesheet : properties * : dirname ? : action )
{   
    STYLESHEET on $(target) = $(stylesheet) ;
    FLAGS on $(target) = [ compute-xslt-flags $(target) : $(properties) ] ;
    NAME on $(target) = $(.xsltproc) ;
    
    for local catalog in [ feature.get-values <catalog> : $(properties) ]
    {
        CATALOG = [ common.variable-setting-command XML_CATALOG_FILES : $(catalog) ] ;
    }
    
    DIRECTORY on $(target) = $(dirname) ;
    $(action) $(target) : $(source) ;
}

rule xslt ( target : source stylesheet : properties * )
{ 
    return [ .xsltproc $(target) : $(source) $(stylesheet) : $(properties) : : xslt-xsltproc ] ;
}

rule xslt-dir ( target : source stylesheet : properties * : dirname )
{ 
    return [ .xsltproc $(target) : $(source) $(stylesheet) : $(properties) : $(dirname) : xslt-xsltproc-dir ] ;
}

actions xslt-xsltproc
{
  $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET)" "$(>)"
}

actions xslt-xsltproc-dir
{
  $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(DIRECTORY)/" "$(STYLESHEET)" "$(>)"
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -