开发者

Is it possible to pass a string containing xml as input to the ant xslt task?

Trying to find out if it's possible to pass a string 开发者_如何学Gocontaining xml as input to the ant xslt task. Thanks!


The short answer is 'no'. But the slightly longer answer is: you can achieve the same by other means.

In one mode, the Ant xslt task will style the file specified by the in attribute, storing the result in the file specified by the out attribute.

<xslt in="src.xml" out="dest.xml" ...>
    ...
</xslt>

So, if you have the XML you want to process stored in an Ant property, you can write that out to 'src.xml' and have it processed by xslt. You can write the property ${xml}(the string) out to a file using something like:

<property name="xml"><![CDATA[
    <myxml>
       ...
    </myxml>]]>
</property>

<echo file="src.xml" message="${xml}" />

Alternatively you might use the echoxml task:

<echoxml file="src.xml">
<myxml>
    ...
</myxml>
</echoxml>

Which method you use will depend on the origin of the 'string'; whether it is raw text, or well-formed XML.


<xslt ...>
 <style>
  <string>
   <![CDATA[
    <xsl:stylesheet ...>
     ... rest of xslt ...
    </xsl:stylesheet>
       ]]>
 </string>
</style></xslt>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜