Transform XML with multiple XSL files

后端 未结 3 2156
一生所求
一生所求 2021-02-19 02:00

I have some XML that I\'d like to transform into HTML using a number of XSL files. These XSL files are all related through xsl:import and xsl:include statements, and all require

3条回答
  •  终归单人心
    2021-02-19 02:46

    If you want a Browser only solution I would do it like this:

    Static xml

    Make a simple static xml that contains only the call to the xsl. This is the xml that is opened in the browser - always. This xml file could contain property settings to control the flow or nothing at all as this example.

    
    
    
    

    Dynamic plain xml

    Generate the dynamic XML in your favourite way using a defined name - in my case cartoons.xml.

    
    
        
        
        
        
        
        
    
    

    XSLT with document load

    Use document loan in the xslt to reference the generated dynamic xml. By using select in the first apply-templates all other templates will work as intended.

    Take a close look at the variable reference at top and the further down in the code. This is where the magic is performed.

    
    
    
        
    
        
            
                
                    Cartoons
                    
                
                
                    
                
            
        
    
        
            
            

    You could save these three files into a directory of choice and open the static xml file in firefox. (Chrome and perhaps Safari has to have the file served through a web server to perform the transformation).

提交回复
热议问题