XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Siarhei BarysiukSubject: 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".

Thanks to all!


Unknownexample(1).zip
Zip archive with example

Posttop
Siarhei BarysiukSubject: XST1.0: create node list as variable (macros implemetation)
Author: Siarhei Barysiuk
Date: 14 Apr 2007 06:18 PM
for converting to node set need to use exsl:node-set for xsltproc

this theme is closed

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.