我知道,我可以用DOM
API在Java中像下面創建xml
文件編程:創建XSLT文件編程
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement("map");
document.appendChild(rootElement);
Element em = document.createElement("string");
em.setAttribute("name", "FirstName");
....
但是否有任何API的構建一個xslt
樹? (一個像大教堂例如API)
我需要somehing這樣的:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:template match="root">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:external-graphic width="100pt" height="100pt" content-width="50pt" content-height="50pt" src="images/shopping-cart_100.jpg"/>
</fo:block>
<fo:block>Good Morning, <xsl:value-of select="name" />!</fo:block>
<fo:block>
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell border="solid 1px black" text-align="center" font-weight="bold">
<fo:block>
和:
<xsl:for-each select="./friend">
<fo:table-row>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="position()" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="name" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
在此先感謝。
'XSLT' is valid'XML',so yes you can。 – climbage
@climbage請花一點時間強調你的評論和回答 – GingerHead
如果你可以構造xml,那麼你可以構造xslt .. xslt是XML ... –