Jump to content

How to pass the dymanic XML file to XSL


jle

Recommended Posts

Hi All,The text below is part of the XSL which is define the object's param for the FLASH. This FLASH object is used bytes.xml file. But instead of hard-coded here bytes.xml I would like to pass this file name to XSL file because each user has different bytes.xml file. So Is there any way that I can pass the file name to XSL file which is defined at the run time. <PARAM NAME="quality" VALUE="high"/> <PARAM NAME="bgcolor" VALUE="#FFFFFF"/> <EMBED src="charts.swf?stage_width=720&stage_height=190&library_path=charts_library&xml_source=xml/bytes.xml" Thanks,JP

Link to comment
Share on other sites

Since XSLT is XML, you can use any XML parser over it to extract whatever data you want.But I don't know the APIs Flash uses. I think it has DOM support, but again, I don't know how it works out. Search for "DOM" in an ActionScript reference and check it out yourself.

Link to comment
Share on other sites

Since XSLT is XML, you can use any XML parser over it to extract whatever data you want.But I don't know the APIs Flash uses. I think it has DOM support, but again, I don't know how it works out. Search for "DOM" in an ActionScript reference and check it out yourself.
Hi All,I would like to make my question clear. I have the xml file is defined in XSL file as below:<PARAM NAME="movie" VALUE="charts.swf" stage_width="720" stage_height="190" library_path="charts_library" xml_source="xml/bytes.xml"/> <PARAM NAME="quality" VALUE="high"/> <PARAM NAME="bgcolor" VALUE="#FFFFFF"/>So I want to define bytes.xml file as variable in XSL and able to set this file in my C++ code. Is it possible.Thanks In advance,JL
Link to comment
Share on other sites

Oh. That. Well, it sure as h#ll is possible. At the top of your XSLT stylesheet, add

<xsl:param name="file" select="'xml/bytes.xml'"/>

and when it comes time to use the parameter, use "{$file}", like so:

<PARAM NAME="movie" VALUE="charts.swf" stage_width="720" stage_height="190" library_path="charts_library" xml_source="{$file}"/>

The value of the "name" attribute can be anything you want (as you can probably guess). The "select" attribute is optional. It only specifies a default value in case you aren't setting the parameter from C++.How do you set the parameter depends on the C++ XSLT processor you're using.

Link to comment
Share on other sites

Oh. That. Well, it sure as h#ll is possible. At the top of your XSLT stylesheet, add
<xsl:param name="file" select="'xml/bytes.xml'"/>

and when it comes time to use the parameter, use "{$file}", like so:

<PARAM NAME="movie" VALUE="charts.swf" stage_width="720" stage_height="190" library_path="charts_library" xml_source="{$file}"/>

The value of the "name" attribute can be anything you want (as you can probably guess). The "select" attribute is optional. It only specifies a default value in case you aren't setting the parameter from C++.How do you set the parameter depends on the C++ XSLT processor you're using.

Hi,Thanks a lot for the detail information related to variable for file in XSL.Sorry for another question that Is it possible to set this parameter ($file) in C++. We are using xalan of ApacheThanks for the help.JP
Link to comment
Share on other sites

Any XSLT processor provides facilities for setting XSLT parameters. Xalan is not an exclusion.I'm not familiar enough with C++, but from experience with other processors and environments, it seems to me the XSLTProcessor class is the class with which you initiate XSLT transformations. The setStylesheetParam() method from this class is the method allowing you to set parameters in the stylesheet (hence the name). This method actually seems to have two synopsis:

void XSLTProcessor::setStylesheetParam (  const XalanDOMString & key, const XalanDOMString & expression ) [pure virtual]  void XSLTProcessor::setStylesheetParam (  const XalanDOMString & key, XObjectPtr value ) [pure virtual]

The first allows you to use the computed value of a specified XPath expression as the parameter. The second allows you to set a specified primive value i.e. a value an XPath expression would otherwise return once evaluated.Again, from lack of experience, I can't give you a concrete sample source code to work from, but I know this is the method you need to investigate.

Link to comment
Share on other sites

Any XSLT processor provides facilities for setting XSLT parameters. Xalan is not an exclusion.I'm not familiar enough with C++, but from experience with other processors and environments, it seems to me the XSLTProcessor class is the class with which you initiate XSLT transformations. The setStylesheetParam() method from this class is the method allowing you to set parameters in the stylesheet (hence the name). This method actually seems to have two synopsis:
void XSLTProcessor::setStylesheetParam (  const XalanDOMString & key, const XalanDOMString & expression ) [pure virtual]  void XSLTProcessor::setStylesheetParam (  const XalanDOMString & key, XObjectPtr value ) [pure virtual]

The first allows you to use the computed value of a specified XPath expression as the parameter. The second allows you to set a specified primive value i.e. a value an XPath expression would otherwise return once evaluated.Again, from lack of experience, I can't give you a concrete sample source code to work from, but I know this is the method you need to investigate.

Hi,Thank you so much for the detail information about setting parameter for XSL.Thanks a ton.JP
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...