Subject:XST1.0: create node list as variable (macros implemetation) Author:Siarhei Barysiuk Date:14 Apr 2007 07:59 AM Originally Posted: 14 Apr 2007 07:50 AM
Hello!
I've try to realize simple macros system in xml I need.
Like this:
1) we define macros in separated file as
<myns:macros name="macro">
<myns:tag1 param1="$width">
<myns:tag2 param2="$length"/>
<myns:tag3 param3="$length"/>
</myns:tag1>
</myns:macros>
2) we use macros in other file as
<myns:use-macros src="macros.xml"
name="macro"
width="100"
length="200"/>
3) we need process macros at runtime and substitute all real
values of parameters(attributes)
$width=100
$length=200
CREATE VARIABLE WITH THESE NODES, SUBSTITUTE REAL VALUES OF VARIABLES
and APPLY TEMPLATES to nodes in this variable (now tree will look like
<myns:tag1 param1="100">
<myns:tag2 param2="200"/>
<myns:tag3 param3="200"/>
</myns:tag1>
except tag <myns:use-macros...> in processed document
)
Now question: Can I create in memory(as xsl:variable) tree which I'll apply templates for further processing?
If I use built-in processor in Stylus Studio all is ok. But if I try to use other processors(such Xalan, Saxon and MS) I have error about converting variable to node list. As I understand I create this variable as RTF (not node list) but how can I create this variable with possibilities to further processing (I use copy and copy-of and all seems ok). Is it possible in XSLT 1.0?
In my application I use xsltproc (XSLT processor in Linux, you can try it under Cygwin enviroment) and it doesn't work too.
I attached small example and result I expect. (Stylus Studio built-in processor generate this result).
If you have any ideas or advices, please, write.
I wouldn't like to use processing in 2 steps
xml_with_macroses->xml_with_processed_macroses->result, would do it "beautiful".