Create xslt files programmatically

前端 未结 3 1951
不知归路
不知归路 2020-12-11 10:53

I know that I can create xml files programmatically by using DOM api in java like the following:

DocumentBuilderFactory do         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 11:35

    Since XSLT it's XML too, you can simply use the same strategy:

    ...
    Document document = documentBuilder.newDocument();
    
    Element rootElement = document.createElement("xsl:stylesheet");
    // adding attributes like namespaces etc...
    
    document.appendChild(rootElement); 
    Element em = document.createElement("xsl:template");
    em.setAttribute("match", "/");
    

    and so on...

    But it's not very elegant. You should use a library or a framework instead, you should easily find one googling around.

提交回复
热议问题