只是一個簡單的問題。我有一個XML,我希望只改變它的一部分而不改變其他任何東西。這裏是什麼,我希望做一個簡單的例子:XSLT一種XML,除了一個部分外,其餘部分都是相同的
輸入:
<?xml version="1.0" encoding="UTF-8"?>
<dita xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/ditabase.xsd">
<topic id="abc">
<title>Sample XML</title>
<body>
<section id="a">
<p> Hello section A </p>
</section>
<section id="b">
<p> General Content </p>
</section>
<section id="c">
<p> Hi thank you for coming from $state </p>
</section>
</body>
</topic>
</dita>
輸出
<?xml version="1.0" encoding="UTF-8"?>
<dita xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/ditabase.xsd">
<topic id="abc">
<title>Sample XML</title>
<body>
<section id="a">
<p> Hello section A </p>
</section>
<section id="b">
<p> General Content </p>
</section>
<section id="c" audience = "WA">
<p> Hi thank you for coming from WA </p>
</section>
<section id="c" audience = NY">
<p> Hi thank you for coming from NY </p>
</section>
<section id="c" audience = "AL">
<p> Hi thank you for coming from AL </p>
</section>
<section id="c" audience = "GA">
<p> Hi thank you for coming from GA </p>
</section>
...
<!--Continue for the rest of the states-->
...
</body>
</topic>
</dita>
我使用XALAN處理器如果能夠有所幫助。非常感謝提前:d
你是否想在'「內替換'$ state',或者在你的輸入文檔中出現的地方? –
2010-07-22 15:00:30
是的我只看到內沒有替換$ state,我希望輸入可以來自XSL文件而不是XML。 –
Bilzac
2010-07-22 15:12:01
好問題(+1)。查看我的答案獲得完整的解決方案。 – 2010-07-22 16:34:26