|
You just have to remember that xsl:call-template works with the current node and doesn't change scope like xsl:apply-templates. Also, xsl:apply-templates has a mode attribute that is used to name it like xsl:call-templates and you can pass parameters to it also.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
wht does it mean when we say that call-template doesnt change scope? bcz after this statement the xsl:template gets called right? so we can change the scope inside the template right?
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
xsl:call-template has is own "scope" as far as variable creation. But the scope of the current node and node-list is the same as its calling parent.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
OK! can u tel me how can we get the parent node of the current node.
<xsl:if test="name()='CallSequence'"><!--Need some fixing to get the sequence right-->
<xsl:apply-templates select="parent()"/>
</xsl:if>
I was thinking that while traversing through the $nodeset I shoujld chk for the existance of another CallSequence Node and the call the same template again recursively.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
It can be "parent::node()" or "parent::*". I think you can specifically check if the parent has a specific name by using "parent::CallSequence"!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I was thinking abt starting a new articles on this but then I changed my mind again... I'm back to the recursive solution again bcz the previous one wasn't showing the right sequence and this recursive one gets a nodeset missed when it starts recursion.
I'm giving the template I made and the XML I'm using.
Here comes the Template!
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="log_style.css" />
<title>Recursive Solution</title>
</head>
<body>
<xsl:apply-templates select="*"/>
</body>
</html>
</xsl:template>
<!--<xsl:template match="CallSequence">
<xsl:for-each select="Call">
<xsl:choose>
<xsl:when test="CallSequence">
<xsl:apply-templates select="CallSequence"/>
</xsl:when>
<xsl:otherwise>
Process the other child nodes
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
-->
<!--Starting: TRYING THE NEW TEMPLATE.... USING Call-Template function-->
<xsl:template name="CallSequenceTemplate" match="CallSequence">
<xsl:for-each select="Call">
<xsl:choose>
<xsl:when test="CallSequence">
<xsl:apply-templates select="CallSequence"/>
</xsl:when>
<xsl:otherwise>
<table>
<br/>
<tr>
<td class='heading3'><b>Call to <xsl:value-of select="Method"/></b></td>
</tr>
</table>
<table width="100%">
<tr><td width="10%">Object Type </td><td><i><xsl:value-of select="ObjectType"/></i></td></tr>
<tr><td>Object Name </td><td><i><xsl:value-of select="ObjectName"/></i></td></tr>
<tr><td>Interface Name </td><td><i><xsl:value-of select="Interface"/></i></td></tr>
<tr><td>Return Code </td><td><i><xsl:value-of select="ReturnCode"/></i></td></tr>
</table>
<xsl:for-each select="Arguments">
<table width = "100%" border="0" class="border" cellpadding="0" cellspacing="1">
<tr><td class='heading4'> </td></tr>
<xsl:if test="Results/Value">
<tr class="nonSelectedRow">
<td colspan="6" class = 'detail_table_element'><b>Inputs</b></td>
</tr>
</xsl:if>
<xsl:if test="Results/Compound">
<tr class="nonSelectedRow">
<td colspan="4" class = 'detail_table_element'><b>Inputs</b></td>
<td colspan="2" class = 'detail_table_element'><b>Output</b></td>
</tr>
</xsl:if>
<tr class="nonSelectedRow">
<xsl:for-each select="*[name() != 'Results'] | Results/child::node()[1] | Results/child::node()[1] / child::node()[2]">
<th><xsl:value-of select="name()"/></th>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="*[node() and name() != 'Results']">
<td valign = "top"><xsl:value-of select="node()"/></td>
</xsl:for-each>
<xsl:if test="Results/Compound">
<td>
<table border="0" width = "100%">
<xsl:for-each select="Results/Compound">
<tr>
<td><xsl:value-of select="Name"/></td>
</tr>
</xsl:for-each>
</table>
</td>
<td>
<table border="0" width = "100%">
<xsl:for-each select="Results/Compound">
<tr>
<td><xsl:value-of select="Value"/></td>
</tr>
</xsl:for-each>
</table>
</td>
</xsl:if>
<xsl:if test="Results/Value">
<xsl:for-each select="Results">
<td><xsl:value-of select="Value"/></td>
</xsl:for-each>
</xsl:if>
</tr>
</table>
</xsl:for-each> <!--Arguments foreach ending-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> <!--Main outer foreach ending-->
</xsl:template><!--CallSequenceTemplate Ending-->
<!--Ending: TRYING THE NEW TEMPLATE.... USING Call-Template function-->
</xsl:stylesheet>
------------------
AND here's the XML
-----------------
<?xml version="1.0" encoding="utf-8"?>
<?xml:stylesheet type="text/xsl" href="d:\\unit example recursive.xsl"?>
<LOG>
<LoggedProgram>C:\Program Files\AspenTech\Aspen HYSYS 2004\hysys.exe</LoggedProgram>
<LogConfiguration>C:\Program Files\Co-LaN\CAPE-OPEN Logger\CAPE-OPENLogs.ini</LogConfiguration>
<LoggedComponent>
<Name>MixNSplit 12</Name>
<CAPE-OPENVersion>1.0</CAPE-OPENVersion>
<Implementation>DLL</Implementation>
<Location>C:\Program Files\Common Files\AspenTech Shared\CAPE-OPEN Example Models\AspenCOUnit100.dll</Location>
<LoggerStatus>Loaded Successfully</LoggerStatus>
</LoggedComponent>
<CallSequence>
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>get_ports</Method>
<ReturnCode>No Error</ReturnCode>
</Call>
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>Validate</Method>
<ReturnCode>No Error</ReturnCode>
<Message>No inlet streams have been connected to this block</Message>
</Call>
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>Calculate</Method>
<CallSequence>
<Call>
<ObjectType>Material Object</ObjectType>
<ObjectName>Mix out</ObjectName>
<Interface>ICapeThermoMaterialObject</Interface>
<Method>SetProp</Method>
<Arguments>
<Property>Volume</Property>
<Phase>Overall</Phase>
<Basis>Mole</Basis>
<Calc>Mixture</Calc>
<Results>
<Value>0.000018075</Value>
</Results>
</Arguments>
<ReturnCode>No Error</ReturnCode>
</Call>
<Call>
<ObjectType>Material Object</ObjectType>
<ObjectName>Mix out</ObjectName>
<Interface>ICapeThermoMaterialObject</Interface>
<Method>GetProp</Method>
<Arguments>
<Property>Fraction</Property>
<Phase>Overall</Phase>
<Basis>mole</Basis>
<Calc>null</Calc>
<Results>
<Compound>
<Name>Hydrogen</Name>
<Value>0.355979900</Value>
</Compound>
<Compound>
<Name>Methane</Name>
<Value>0.018735784</Value>
</Compound>
<Compound>
<Name>Benzene</Name>
<Value>0.401813320</Value>
</Compound>
<Compound>
<Name>Toluene</Name>
<Value>0.223470992</Value>
</Compound>
<Compound>
<Name>BiPhenyl</Name>
<Value>0.000000005</Value>
</Compound>
<Compound>
<Name>H2O</Name>
<Value>0.703552320</Value>
</Compound>
</Results>
</Arguments>
<ReturnCode>No Error</ReturnCode>
</Call>
</CallSequence>
<ReturnCode>No Error</ReturnCode>
</Call>
<Call>
<ObjectType>testing object</ObjectType>
<ObjectName>Backto 1st</ObjectName>
<Interface>Rocky</Interface>
<Method>Checking the sequence </Method>
<ReturnCode>no</ReturnCode>
<Message>checking the back track</Message>
</Call>
</CallSequence>
</LOG>
---------------------------------------------------
I'm sorry for giving such a long post but if u see the results u can see what the problem is... Can u or any buddy plz remove this bug!!. I've tried my heart out since yesterday and its not working!
Rocky
You can't climb up a ladder with your hands in your pockets.
-- modified at 2:44 Friday 7th September, 2007
|
|
|
|
|
I've found why this is missing the calling functions data
<xsl:template match="CallSequence">
<xsl:for-each select="Call">
<xsl:choose>
<xsl:when test="CallSequence">
<xsl:apply-templates select="CallSequence"/>
</xsl:when>
<xsl:otherwise>
<!--Process the other child nodes-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
As you can see this isthe basic model of recursion I'm using which was proposed by you previously. What happens is that that this condition in the choose-when actually doesnt consider whether there are some nodes above another CallSequence Clause.
<xsl:template match="CallSequence">
<xsl:for-each select="Call">
<xsl:choose>
<xsl:when test="CallSequence">
<xsl:apply-templates select="CallSequence"/>
</xsl:when>
--------------
see this section of XML
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>Calculate</Method>
<CallSequence>
<Call>
--------------
I've tried to change the conditions but its no help
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
FINALLY !! I've DONE it... The EUREKA moment has come and I thought I should tell u first?
Thanks a lot George... Its been a pleasure!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
That's definately true!
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Congrats! I bet you learned a lot about XSLT doing this exercise. Make sure you write down what you experienced for future reference.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Yes. definately that was a really good one! I learned alot from that.
I'll definately make some notes and save that work as well.
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
hi how ru doing?
Can u plz tell me how i can get the distint nodes in an XML. I've searched and found these two options
distinct-nodes function
for-each-group function
and the distinct-values function but I havent been able to use them properly. They belong to XSLT 2.0 and well seems to me like somethings missing. Either the namespace or something? how should I declare it? and I've also visited the saxon website. What exactly do i need to download from there?? I'm confused ?
thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Actually, I am still studying XSLT 2.0 and haven't looked at those functions yet. If I get a chance, I'll play around with those functions a bit.
Saxon-SA 8.9 is the commercial XSLT 2.0 product and Saxon-B 8.9 is the open source one. I believe both products for .NET are really written in Java underneath. Here is the linke again: http://saxon.sourceforge.net/[^].
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
ok any ideas abt getting unique nodes from an xml document. for example if u have this kind of a structure
<a></a>
<b></b>
<a></a>
<b></b>
<a></a>
<b></b>
how can u get only a and b
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Hello,
i have a problem with retrieving a jagged array from my webservice the array looks like this:
Array ( [0] => Array ( [0] => id [1] => int(11) [2] => YES [3] => [4] => ) [1] => Array ( [0] => name [1] => varchar(255) [2] => YES [3] => [4] => ) )
SyncITSoap SyncITSoap = new SyncITSoap();
object columns = SyncITSoap.getColumns("", "", "syncit","test");
error message when the methode is called getColumns = {"The specified type was not recognized: name='Columns', namespace='http://server.e-ss.nl:8100/service', at <columns xmlns=''>."}
can somebody help me out? thx in advance
wdsl is this:
WDSL Jagged array problem
<?xml version="1.0" encoding="utf-8"?>
<definitions
name="SyncIT"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
targetNamespace="http://server.e-ss.nl:8100/service"
xmlns:tns="http://server.e-ss.nl:8100/service"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema targetNamespace="http://server.e-ss.nl:8100/service" xmlns:impl="http://server.e-ss.nl:8100/service" xmlns="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Database">
<xsd:all>
<xsd:element name="name" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="DatabaseArray">
<xsd:complexContent mixed="false">
<xsd:restriction base="soapenc:Array">
<xsd:attribute foobar:arrayType="tns:Database[]" ref="soapenc:arrayType" xmlns:foobar="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Table">
<xsd:all>
<xsd:element name="name" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="TableArray">
<xsd:complexContent mixed="false">
<xsd:restriction base="soapenc:Array">
<xsd:attribute foobar:arrayType="tns:Table[]" ref="soapenc:arrayType" xmlns:foobar="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="Columns">
<xsd:complexContent mixed="false">
<xsd:restriction base="soapenc:Array">
<xsd:attribute foobar:arrayType="xsd:string[]" ref="soapenc:arrayType" xmlns:foobar="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ColumnArray">
<xsd:complexContent mixed="false">
<xsd:restriction base="soapenc:Array">
<xsd:attribute foobar:arrayType="tns:Columns[]" ref="soapenc:arrayType" xmlns:foobar="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="getDatabasesRequest">
<part name="login" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="getDatabasesResponse">
<part name="databases" type="tns:DatabaseArray"/>
</message>
<message name="getTablesRequest">
<part name="login" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="db" type="xsd:string"/>
</message>
<message name="getTablesResponse">
<part name="tables" type="tns:TableArray"/>
</message>
<message name="getColumnsRequest">
<part name="login" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="db" type="xsd:string"/>
<part name="table" type="xsd:string"/>
</message>
<message name="getColumnsResponse">
<part name="columns" type="tns:ColumnArray"/>
</message>
<portType name="SyncITPort">
<operation name="getDatabases">
<input message="tns:getDatabasesRequest"/>
<output message="tns:getDatabasesResponse"/>
</operation>
<operation name="getTables">
<input message="tns:getTablesRequest"/>
<output message="tns:getTablesResponse"/>
</operation>
<operation name="getColumns">
<input message="tns:getColumnsRequest"/>
<output message="tns:getColumnsResponse"/>
</operation>
</portType>
<binding name="SOAP" type="tns:SyncITPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getDatabases">
<soap:operation soapAction="urn:syncitsoap#getDatabases"/>
<input>
<soap:body use="encoded" namespace="urn:syncitsoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:syncitsoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="getTables">
<soap:operation soapAction="urn:syncitsoap#getTables"/>
<input>
<soap:body use="encoded" namespace="urn:syncitsoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:syncitsoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="getColumns">
<soap:operation soapAction="urn:syncitsoap#getColumns"/>
<input>
<soap:body use="encoded" namespace="urn:syncitsoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:syncitsoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="SyncITSoap">
<port name="SyncITPort" binding="tns:SOAP">
<soap:address location="http://server.e-ss.nl:8100/service/service.php"/>
</port>
</service>
</definitions>
|
|
|
|
|
Hi all,
well I'm trying to use the xsl:call-template statement to call the template I wanna make to show the CallSequence/Call portion of my XML. As you can see that its recursive that is, you can get another CallSequence/Call inside a LOG/CallSequence/Call
Here's portion of the XML to illustrate on this:-
<CallSequence>
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>get_ports</Method>
<ReturnCode>No Error</ReturnCode>
</Call>
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>Validate</Method>
<ReturnCode>No Error</ReturnCode>
<Message>No inlet streams have been connected to this block</Message>
</Call>
<Call>
<ObjectType>Unit</ObjectType>
<ObjectName>ChemSepUO_382</ObjectName>
<Interface>ICapeUnit</Interface>
<Method>Calculate</Method>
<CallSequence>
<Call>
<ObjectType>Material Object</ObjectType>
<ObjectName>Mix out</ObjectName>
<Interface>ICapeThermoMaterialObject</Interface>
<Method>SetProp</Method>
<Arguments>
<Property>Volume</Property>
<Phase>Overall</Phase>
<Basis>Mole</Basis>
<Calc>Mixture</Calc>
<Results>
<Value>0.000018075</Value>
</Results>
</Arguments>
<ReturnCode>No Error</ReturnCode>
</Call>
AND THE TEMPLATE I'M TRYING TO BUILD IS
<xsl:template name="Call_Details" match="CallSequence/Call">
<xsl:for-each select="CallSequence/Call">
<table width="100%" >
<br/>
<tr>
<td class='heading3'><b>Call to <xsl:value-of select="Method"/></b></td>
</tr>
</table>
<table width="100%">
<tr><td width="10%">Object Type </td><td><i><xsl:value-of select="ObjectType"/></i></td></tr>
<tr><td>Object Name </td><td><i><xsl:value-of select="ObjectName"/></i></td></tr>
<tr><td>Interface Name </td><td><i><xsl:value-of select="Interface"/></i></td></tr>
<tr><td>Return Code </td><td><i><xsl:value-of select="ReturnCode"/></i></td></tr>
</table>
<xsl:for-each select="Arguments">
<table width = "100%" border="0" class="border" cellpadding="0" cellspacing="1" >
<tr><td class="heading4"> </td></tr>
<xsl:if test="Results/Value"><!--*Either one of these two XSL IF clauses will run -->
<tr class="nonSelectedRow">
<td colspan="6" class = 'detail_table_element'><b>Inputs</b></td>
</tr>
</xsl:if>
<xsl:if test="Results/Compound"><!--** -->
<tr class="nonSelectedRow">
<td colspan="4" class = 'detail_table_element'><b>Inputs</b></td>
<td colspan="2" class = 'detail_table_element'><b>Output</b></td>
</tr>
</xsl:if>
<tr class="nonSelectedRow">
<xsl:for-each select="*[name() != 'Results'] | Results/child::node()[1] | Results/child::node()[1] / child::node()[2]">
<th><xsl:value-of select="name()"/></th>
</xsl:for-each>
<!-- to print the property, phase, etc etc results-->
</tr>
<tr>
<xsl:for-each select="*[node() and name() != 'Results']">
<td valign = "top"><xsl:value-of select="node()"/></td>
</xsl:for-each>
<xsl:if test="Results/Compound">
<td>
<table border="0" width = "100%">
<xsl:for-each select="Results/Compound">
<tr>
<td><xsl:value-of select="Name"/></td>
</tr>
</xsl:for-each>
</table>
</td>
<td>
<table border="0" width = "100%">
<xsl:for-each select="Results/Compound">
<tr>
<td><xsl:value-of select="Value"/></td>
</tr>
</xsl:for-each>
</table>
</td>
</xsl:if>
<xsl:if test="Results/Value">
<xsl:for-each select="Results">
<td><xsl:value-of select="Value"/></td>
</xsl:for-each>
</xsl:if>
</tr>
</table>
</xsl:for-each> <!--Arguments for-each ends here-->
<table width="100%">
<tr><td class='heading3'><b><xsl:value-of select="Method"/> Ends</b></td></tr>
</table>
</xsl:for-each>
</xsl:template>
---------------------------------------------------
I'm calling it in this way...
xml:call-template name="Call_Details">
</xml:call-template>
but there's no output for it...
Any ideas??
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
You need to know what the current node is since xsl:call-template does not change the current node. If the parent template matches with "/CallSequence/Call", then the current node is "Call". If the parent template matches with "/CallSequence", then the current node is "CallSequence"; you have access to the child nodes of CallSequence, and your xsl:for-each select would be "Call".
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi everyone,
well I'm kind of a new bee here and I wanted to ask a bit naive questions so here it goes. How do we know whether we can use XSL 2.0?
Actually I was trying to use the new 'replace' function in XSLT. I changed the header to
<xsl:stylesheet version="2.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform">
but its giving me error that replace is not a valid XSLT or XPath Function. So what should I do now? Any ideas??
Thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
|
|
Here is some sample code for XSLT Extension Object that I had playing around with recently:
using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Xml;
using namespace System::Xml::XPath;
using namespace System::Xml::Xsl;
public ref class ParseCdata
{
public:
ParseCdata(String^ xmlText) : doc(gcnew XmlDocument)
{
doc->LoadXml(xmlText);
}
String^ GetCData(XPathNodeIterator^ nodes)
{
StringBuilder^ result = gcnew StringBuilder;
while (nodes->MoveNext())
{
XPathNavigator^ nodesNav = nodes->Current;
String^ xpath = String::Format("/test/data[@id='{0}']",
nodes->Current->GetAttribute("id", String::Empty));
XmlNodeList^ dataNodes = doc->SelectNodes(xpath);
for each (XmlNode^ node in dataNodes)
{
for each (XmlNode^ child in node->ChildNodes)
{
if (child->NodeType == XmlNodeType::CDATA)
result->AppendFormat("-!!!{0}!!!-", child->Value);
}
}
}
return result->ToString();
}
private:
XmlDocument^ doc;
};
int main(array<System::String ^> ^args)
{
String^ xmlText =
"<?xml version='1.0'?>"
"<test>"
" <data id='1'><![CDATA[CDATA1]]><![CDATA[CDATA2]]></data>"
"</test>";
String^ xsltText =
"<?xml version='1.0'?>"
"<xsl:stylesheet version='1.0' "
" xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
" xmlns:extObj='urn:cdata-conv'>"
"<xsl:template match='/'>"
"<result>\n"
"\t<xsl:apply-templates select='test/data'/>\n"
"</result>\n"
"</xsl:template>"
"<xsl:template match='data'>"
"<xsl:value-of select='extObj:GetCData(.)'/>"
"</xsl:template>"
"</xsl:stylesheet>";
StringReader^ strReader1;
XmlReader^ xmlReader1;
StringReader^ strReader2;
XmlReader^ xmlReader2;
try
{
strReader1 = gcnew StringReader(xsltText);
xmlReader1 = XmlReader::Create(strReader1);
XslCompiledTransform^ xslt = gcnew XslCompiledTransform;
xslt->Load(xmlReader1);
strReader2 = gcnew StringReader(xmlText);
xmlReader2 = XmlReader::Create(strReader2);
XPathDocument^ xml = gcnew XPathDocument(xmlReader2);
XsltArgumentList^ xsltArgs = gcnew XsltArgumentList;
ParseCdata^ cdata = gcnew ParseCdata(xmlText);
xsltArgs->AddExtensionObject("urn:cdata-conv", cdata);
xslt->Transform(xml, xsltArgs, Console::Out);
}
catch (Exception^ excp)
{
Console::WriteLine(excp->ToString());
}
finally
{
if (xmlReader2 != nullptr)
xmlReader2->Close();
if (strReader2 != nullptr)
strReader2->Close();
if (xmlReader1 != nullptr)
xmlReader1->Close();
if (strReader1 != nullptr)
strReader1->Close();
}
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
any one please tell me how to read http xml attribute values and CDATA part using javascript...
it's urgent please... help me...
Pradeep Reddy
|
|
|
|
|
Hi everyone,
well I'm building an XSL Style sheet here and i thought it would be a really nice feature if i could show the names of my nodes which are mostly in the form : 'LogConfiguration' to 'Log Cofiguration'
For now my problem is just to know how to convert such a string into this form.
Thanks in advance
Rocky
You can't climb up a steep ladder with your hands in your pockets.
|
|
|
|
|
Hi
I am getting following error on connection string in xmlbulkload:
"QueryInterface for interface SQLXMLBULKLOADLib.ISQLXMLBulkLoad failed."
Thanks
Hardik Panchal
|
|
|
|
|
i got the solution
tx
Hardik Panchal
|
|
|
|
|
Would you please suggest me taht how to process large .csv files(more than 1000 lines) FASTER, so that it can be processed faster by XML Processor to convert into xml files.
But it works with small file(less than 1000 lines). But incase of large .csv files it gives following Memory Managament Error.
"Your system is low on virtual memory.Windows is increasing the size of the virtual memory paginf file...."
Please solve my problem with the code in C#.NET
With Regards
Tapan
|
|
|
|