|
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
|
|
|
|
|
hi every buddy!
well I'm trying to display the XML data (sample given below ) in a table using XSL and as i've highlighted in the XML the results node is the one giving me trouble. I'm trying to do this in XSL as:
<tr class="nonSelectedRow">
<pre><xsl:for-each select="*[node() and node()!='Results']"></pre>
<th><xsl:value-of select="name()"/></th>
</xsl:for-each>
</tr>
-------------------------------------------
The problem is that I wanna display the data in two seperate tables such as
<pre>----------------------------------------
inputs |
----------------------------------------
property | phase | basis | calc | Value |
----------------------------------------</pre>
and...........
<pre>
----------------------------------------------------
inputs | Outputs |
----------------------------------------------------
property | phase | basis | calc | Compound |Value |
----------------------------------------------------</pre>
The XML part is given here:
--------------------------------
<code>
<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>
<pre> <Results>
<Value>0.000018075</Value>
</Results></pre>
</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>
<pre> <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>
</Results></pre>
</Arguments>
<ReturnCode>No Error</ReturnCode>
</Call>
</CallSequence>
</code>
Can anyone tell me how to display the data in this format using the way I'm trying to do in XSL. Coz I wanna make it as general as possible. I dont wanna be specific so that it can cater the changes in the future.
Thanks in advance!!!
Rocky
You can't climb up a <i>steep</i> ladder with your hands in your pockets.
|
|
|
|
|
<?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>
<title>Call Sequence</title>
</head>
<body>
<xsl:apply-templates select="CallSequence/Call/Arguments"/>
</body>
</html>
</xsl:template>
<xsl:template match="Arguments">
<table>
<tr>
<xsl:apply-templates select="*[name() != 'Results'] | Results/child::node()[1] | Results/child::node()[1] / child::node()[2]"/>
</tr>
</table>
</xsl:template>
<xsl:template match="*">
<th><xsl:value-of select="name()"/></th>
</xsl:template>
</xsl:stylesheet>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks u so much George, that worked for me, actually I modified it and used only this part
*[name() != 'Results'] | Results/child::node()[1] | Results/child::node()[1] / child::node()[2]
just for the confirmation i wanna ask you that '[2]' selects two child nodes right??
and by the way can u tell me the name of some really good book on XML/XSL?
Thanks again... you Rock
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
The XPath 'Results/child::node()[1]/child::node()[2]' selects the second child 'child::node()[2]' of the first child 'child::node()[1]' of the element 'Results'. The '[2]' actually means 'position() = 2'. You can kind of think of '[2]' as an array index, where the base is 1.
I have learned XSLT from the first edition of this book:
XSLT Programmer's Reference, Second Edition
by Michael Kay
Wrox Press © 2001 (938 pages)
ISBN:0764543814
There is also a third edition the covers XSLT 2.0:
XSLT 2.0 Programmer's Reference, Third Edition
by Michael Kay
Wrox Press © 2004 (955 pages)
They have a tutorial/reference type structure which makes them useful for some time.
I also found the following useful also:
XSLT Cookbook, Second Edition
by Sal Mangamo
O'Reilly Media,Inc. © 2006 (751 pages)
ISBN: 0-596-00974-7
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks very much u know I really appreciate this. I'll try and get hold of these books!
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
Alternative:
<?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>
<title>Call Sequence</title>
</head>
<body>
<xsl:apply-templates select="CallSequence/Call/Arguments"/>
</body>
</html>
</xsl:template>
<xsl:template match="Arguments">
<table>
<tr>
<xsl:apply-templates select="*"/>
</tr>
</table>
</xsl:template>
<xsl:template match="*">
<th><xsl:value-of select="name()"/></th>
</xsl:template>
<xsl:template match="Results">
<xsl:apply-templates select="*[1] | *[1]/Value"/>
</xsl:template>
</xsl:stylesheet>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
i'd would like to add that line <?xml-stylesheet type=\"text/xsl\" href=\"{0}\"?>
to my xml file using the xmlDocument-Class but i don't know how? Atm i use the following code
using (XmlWriter writer = XmlWriter.Create(FullFilePath, settings))
{
writer.WriteRaw(string.Format("<?xml-stylesheet type=\"text/xsl\" href=\"{0}\"?>", Globals.StylesheetXSL));
writer.WriteStartElement("root");
writer.WriteEndElement();
writer.Flush();
writer.Close();
}
-- modified at 10:49 Thursday 30th August, 2007
|
|
|
|
|
error1408 wrote: using the xmlDocument-Class
error1408 wrote: using (XmlWriter writer = XmlWriter.Create(FullFilePath, settings))
XmlWriter is NOT XmlDocument. I strongly recommend you use the documentation[^] to find information.
|
|
|
|
|
I KNOW, that is the code I use at the moment...
I do not know how to do exactly the same with the xmlDocument-Class. Thats why i'm asking.
|
|
|
|
|
error1408 wrote: I do not know how to do exactly the same with the xmlDocument-Class.
I fail to see how that negates my original reply... I strongly recommend you use the documentation to find information.
|
|
|
|