XSLT stylesheet parameters in imported stylesheets

后端 未结 4 2319
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 04:39

Is it possible to assign a value to a parameter of an imported stylesheet?

I was expecting something like


  

        
4条回答
  •  不要未来只要你来
    2021-02-19 05:22

    Just to add to lwburk's excellent answer (+1), here's one more example of assigning a value to a parameter in an imported stylesheet.

    You wouldn't need to add xsl:param to the main stylesheet; you would just assign the value when you called the stylesheet (on the command line for example).

    main.xsl

    
    
      
    
      
            
      
    
    
    

    import.xsl

    
      
    
      
    
      
            
      
    
    
    

    example saxon command line (setting new parameter value)

    java -cp "saxon9.jar" net.sf.saxon.Transform -s:input.xml -xsl:main.xsl -o:output.xml param="kuba"
    

    output.xml

    kuba
    

提交回复
热议问题