|
you have to do this using server-side code.
client side code is not a good idea as you will face the problems that you have now.
you need to write this in code that executes on the webserver, so either asp or asp.net depending on which one you know.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi,
I am using MSXML to get the response from a web server. It's really strange that everytime before I can load that page successfully, I should load that url first in my IE. Only after that, the page can be loaded in my program.
Can someone kindly tell me what the problem could be?
Thanks and nice day!
<br />
BOOL CAPIDlg::MakeRequest() {<br />
try{<br />
MSXML::IXMLHttpRequestPtr pIXMLHTTPRequest;<br />
HRESULT hResult=CoInitialize(NULL);;<br />
hResult = pIXMLHTTPRequest.CreateInstance("Microsoft.XMLHTTP");<br />
pIXMLHTTPRequest->open("POST",(_bstr_t)"http://www.yahoo.com");<br />
pIXMLHTTPRequest->send();<br />
m_XMLResult.SetWindowText(pIXMLHTTPRequest->responseText);<br />
}<br />
catch(...) {<br />
}<br />
return true;<br />
}<br />
|
|
|
|
|
Hi, I find out the mistake
The method is
pIXMLHTTPRequest->open("POST",(_bstr_t)"http://www.yahoo.com");
shoud be "GET" instead of "POST".
|
|
|
|
|
how to do the following using .NET
I have the following XML document :
<a>3.14159</a>
If I were using COM MSXML parser, I could get
NodeTypedValue property to get "strongly-typed"
value.
b= XMLDocument.SelectSingleNode("//b");
variant value = b.NodeTypedValue;
//now the variant contains double value.
The question is:
how to achieve the same using C# ?
Value property of XMLNode object returns String
type, wchich i have to convert to get desired type...
How to do this without explicit conversion (by the means
of XMLConvert class or similar...)
Thanks
Michal Januszczyk
|
|
|
|
|
I have an XML document which is as follows :
<NODE name="a">
<NODE name="b">
<NODE name="c"/>
</NODE>
</NODE>
the XSL output needs to be
a
b
c
can i do this using XSL? I am unable to do a nested looping that indents . Please help .
|
|
|
|
|
Hi,
here's an example of this I knocked together for a friend a while ago..
*********XML*********
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="xmlnav.xsl"?>
<navigation>
<menu name="menu 1">
<option name="LEVEL 1" path="/xmlnav/level1.asp">
<option name="test level 1" path="/xmlnav/level1test.asp">
<option name="test level 1 sub option" path="/xmlnav/suboption.asp"/>
<option name="test level 1 sub option 2" path="/xmlnav/level1test.asp">
<option name="test level 1 sub sub option" path="/xmlnav/suboption.asp"/>
</option>
</option>
<option name="test level 2" path="/xmlnav/level2test.asp"/>
<option name="test level 3" path="/xmlnav/level3test.asp"/>
</option>
</menu>
<menu name="menu 2">
<option name="LEVEL 2" path="/xmlnav/level2.asp">
<option name="test menu2 sub option" path="/xslnav/suboption2.asp"/>
</option>
</menu>
</navigation>
---------------8<---------------
*********XSL*********
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"/>
<xsl:param name="path"/>
<xsl:template match="/">
<html>
<head>
<style type="text/css">
body, td { font-family: arial; font-size: 12px }
</style>
</head>
<body>
<p>Matching company: <xsl:value-of select="$path"/></p>
<xsl:for-each select="navigation/menu">
<xsl:value-of select="@name"/><br/>
<xsl:for-each select="child::option">
<xsl:call-template name="alink">
<xsl:with-param name="nesting" select="0" />
<xsl:with-param name="loop" select="0" />
</xsl:call-template>
<br />
<xsl:call-template name="chld" >
<xsl:with-param name="nesting" select="0" />
<xsl:with-param name="loop" select="0" />
</xsl:call-template>
</xsl:for-each>
<br />
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template name="chld">
<xsl:param name="loop" />
<xsl:param name="nesting" />
<xsl:for-each select="child::option">
<xsl:call-template name="alink">
<xsl:with-param name="loop" select="$loop" />
<xsl:with-param name="nesting" select="$nesting + 1" />
</xsl:call-template>
<br />
<xsl:call-template name="chld">
<xsl:with-param name="loop" select="$loop" />
<xsl:with-param name="nesting" select="$nesting + 1" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="space">
</xsl:template>
<xsl:template name="alink">
<xsl:param name="loop" />
<xsl:param name="nesting" />
<xsl:if test="not($loop > $nesting)">
    
<xsl:call-template name="alink">
<xsl:with-param name="loop" select="$loop + 1"/>
<xsl:with-param name="nesting" select="$nesting"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$loop=$nesting">
<a>
<xsl:attribute name="href"><xsl:value-of select="@path"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
---------------8<---------------
that should be more than enough to get you going
if you need an explanation then give me a shout, and I will do my humble best to clarify it.
HTH
|
|
|
|
|
This work ok . I had one more question . Now How can i diagramatically represent this heirarchical data ? Like everything is in One level I need some indentation !
Like
CRange
CKeyboard
COven
CDigitalInput
CDigitalOutput
CSettings
this would be really cool . This seems easy when programming in C/C++ , but how do i make XSL do this ?
|
|
|
|
|
Dinner time so I have to go.
Look up the parameter passing to templates. One option would be to just send a text string of blanks that is increased with each call and put that text out prior to the name you have.
www.w3schools should have a sample
""
|
|
|
|
|
My XML Document is the following
<OBJECT Class="CRange" Name="objName"><br />
<OBJECT Class="CKeyboard" Name="objName"/><br />
<OBJECT Class="COven" Name="objName"><br />
<OBJECT Class="CDigitalInput" Name="objName"/><br />
<OBJECT Class="CDigitalOutput" Name="objName"/><br />
</OBJECT><br />
<OBJECT Class="CSettings" Name="objName"/><br />
</OBJECT>
My XSLT CODe is as
<?xml version="1.0" encoding="ISO-8859-1"?><br />
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><br />
<xsl:template match="/"><br />
<html><br />
<body><br />
<h2>AOM MODEL</h2><br />
<br>top</br><br />
<xsl:apply-templates select="OBJECT"/><br />
<xsl:for-each select="OBJECT"><br />
<xsl:apply-templates select="OBJECT"/><br />
<xsl:for-each select="OBJECT"><br />
<xsl:apply-templates select="OBJECT"/><br />
<xsl:for-each select="OBJECT"/><br />
</xsl:for-each><br />
</xsl:for-each><br />
<br />
<br />
<br />
</body><br />
</html><br />
</xsl:template><br />
<xsl:template match="OBJECT"><br />
<span style="color:#0000FF"><br />
<br><br />
<xsl:value-of select="@Class"/><br />
</br><br />
</span><br />
</xsl:template><br />
<xsl:template match="PROPERTY"><br />
<br><br />
<span style="color:#ff0000"><br />
<xsl:value-of select="."/><br />
</span><br />
</br><br />
</xsl:template><br />
</xsl:stylesheet>
The output is
AOM MODEL
top
CRange
CKeyboard
COven
CSettings
CDigitalInput
CDigitalOutput
This does not reflect the heirarchy and is wrong . What should i be doing to get
AOM MODEL
top
CRange
CKeyboard
COven
CDigitalInput
CDigitalOutput
CSettings
what am i doing wrong ? I basically need a tree traversal ? Please help
|
|
|
|
|
Is this what you want?
What processor are you using?
I had to change the xmlns to something newer to run this through MSXML 4.
I also had to correct the case of the match and select values to your xml file.
**************** XML FILE *****************
<object Class="CRange" Name="objName">
<object Class="CKeyboard" Name="objName"/>
<object Class="COven" Name="objName">
<object Class="CDigitalInput" Name="objName"/>
<object Class="CDigitalOutput" Name="objName"/>
</object>
<object Class="CSettings" Name="objName"/>
</object>
*************** XSL FILE ********************
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<h2>AOM MODEL</h2>
<br>top</br>
<xsl:apply-templates select="object"/>
</body>
</html>
</xsl:template>
<xsl:template match="object">
<span style="color:#0000FF">
<br>
<xsl:value-of select="@Class"/>
</br>
</span>
<xsl:apply-templates select="object"/>
</xsl:template>
<xsl:template match="PROPERTY">
<br>
<span style="color:#ff0000">
<xsl:value-of select="."/>
</span>
</br>
</xsl:template>
</xsl:stylesheet>
************** out put ******************
AOM MODEL
top
CRange
CKeyboard
COven
CDigitalInput
CDigitalOutput
CSettings
<b><i>""</i></b>
|
|
|
|
|
How to display More than one XML file data using same XXLTransform object?
|
|
|
|
|
I have a xml-schema in which two elements are defined, as in code below. The first one is included in the second one using ref=”element1”. From this schema I define a dataset using DataSet.ReadXmlSchema() (in C#). The simple data types, as string and int are easy to store data in, but how do I store an object of the first element type into the dataset? I have tried to first store it in a DataRow (defined as in the xml-schema of element1) and then add it to the other Dataset, but this does not work. An Int32 type is expected for the ref-element, is this a handle to the other element? If so how do I get that handle?
Any help will be greatly appreciated!
/EnkelIk
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Register" xmlns:xs = "http://www.w3.org/2001/XMLSchema" version ="1.0"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Element1">
<xs:complexType>
<xs:sequence>
<xs:element name="str1" nillable="true" type="xs:string" />
<xs:element name="str2" nillable="true" type="xs:string" />
<xs:element name="str3" nillable="true" type="xs:string" />
<xs:element name="str4" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Element2">
<xs:complexType>
<xs:sequence>
<xs:element name="mystr1" nillable="true" type="xs:string" />
<xs:element name="mystr2" nillable="true" type="xs:string" />
<xs:element ref="Element1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
|
|
|
|
|
I'm having problems defining an array in xml.
I have defined an xml schema in a file and I create a dataset by loading the schema (in C#: DataSet.ReadXmlSchema(filename) ). It works fine for "complex types" containing strings, ints and so on, but when I try defining an array the error message reads:
"Undefined complexType 'http://schemas.xmlsoap.org/soap/encoding/:Array' is used as a base for complex type restriction".
How come the Array type is undefined? Many schemas use the same syntax from what I can tell. What am I missing?
Below is part of the xml-schema I try to use:
<xs:schema id="Register" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:s3="http://vo.lpw.ldk" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<xs:import namespace="http://schemas.xmlsoap.org/soap/encoding/">
<xs:element name="Register" msdata:isdataset="true" msdata:locale="sv-SE">
<xs:complextype>
<xs:choice maxoccurs="unbounded">
<xs:element name="ArrayOf_tns3_ProgRes">
<xs:complextype>
<xs:complexcontent mixed="false">
<xs:restriction base="soapenc:Array">
<xs:sequence>
<xs:element name="item" type="ProvRes" minoccurs="0" maxoccurs="unbounded">
<xs:attribute d7p1:arraytype="s3:ProvRes[]" ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/">
<xs:element name="ProgRes">
<xs:complextype>
<xs:sequence>
<xs:element name="string1" nillable="true" type="xs:string">
<xs:element name="string2" nillable="true" type="xs:string">
Best regards
/EnkelIk
|
|
|
|
|
Oops forgot to check the "display as is" checkbox.
This is the schema I try to use:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Register" xmlns="" xmlns:xs = "http://www.w3.org/2001/XMLSchema" version = "1.0"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:s3="http://vo.lpw.ladok" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/">
<xs:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xs:element name="Register" msdata:IsDataSet="true" msdata:Locale="sv-SE">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="ArrayOf_tns3_ProgRes">
<xs:complexType>
<xs:complexContent mixed="false">
<xs:restriction base="soapenc:Array">
<xs:sequence>
<xs:element name="item" type="ProvRes" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute d7p1:arrayType="s3:ProvRes[]" ref="soapenc:arrayType" xmlns:d7p1="http://schemas.xmlsoap.org/wsdl/" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="ProgRes">
<xs:complexType>
<xs:sequence>
<xs:element name="string1" nillable="true" type="xs:string" />
<xs:element name="string2" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
|
|
|
|
|
Did you ever figure it out, I'am having the same problem.
Thanks, Louis.
|
|
|
|
|
No, I'm sorry -I didn't. That is I found another solution. It is quite some time ago of course but from what I remember and looking into the code, I found a solution so I could manage without arrays -I simply created a more "database like" schema, so I gave element A an identity (say A1) and then in element B I introduced a property with the value of the id of the A-element to which B belonged. In the xsl I then treated element A1, selected all B-elements that belonged to A1 and managed them, then going on to the next A-element. It would have been a lot nicer with arrays of course.
I'm not sure if I will try and solve it again some day, now that I have a bit more experience of xml/xsl, but if you solve it I'm very interested to hear how you did it.
Thanks
/EnkelIk
|
|
|
|
|
I have just downloaded V3 of the SOAP toolkit from MS. The docs imply it should be possible to link a SOAP request on to most COM components using the WSDL Generator to create the needed files. So...
Does the panel think it would be possible to use an MFC app (with a dual interface to get the required IDISPATCH) as the target for SOAP.
If so this could make for a very nice remote control technique which avoids the horrors of DCOM - been there, done that, gave it up as a bad job .
Wild guesses and educated musings welcome.
Cheers
Steve
|
|
|
|
|
Someone can tell me the difference betweem xsl:import and xsl:include ? I can't get it Please don't post a description from MSDN here I have it already
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
From w3schools: Note the precedence comment.
IMPORT
http://www.w3schools.com/xsl/el_import.asp
The <xsl:import> element is a top-level element that is used to import the contents of one style sheet into another.
Note: An imported style sheet has lower precedence than the importing style sheet.
Note: This element must appear as the first child node of <xsl:stylesheet> or <xsl:transform>.
Note: Netscape 6 does not support import precedence, so this element will behave equivalent to <xsl:include>.
INCLUDE
http://www.w3schools.com/xsl/el_include.asp
Definition and Usage
The <xsl:include> element is a top-level element that includes the contents of one style sheet into another.
Note: An included style sheet has the same precedence as the including style sheet.
Note: This element must appear as a child node of <xsl:stylesheet> or <xsl:transform>.
EDIT - do not know why the sentences got trimmed but I think you can see the difference - end edit.
"I will find a new sig someday."
|
|
|
|
|
Hmm.... precedence... Can you give me a small example? Is that like this scenario:
Both imported and importing XSLTs has a xsl:template named "template". But only the importing (main) will work in case of xsl:import , right? In case of xsl:include both will be called? Same if 2 templates has same match attribute?
I think I'm lost, lol
<edited>
or in both cases they will be called, but when use import the template from main XSLT will be used first and always?
</edited>
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
You got the concept.
Make a few simple examples and step through them.
If you can not justify a xslt edit/debug purchase, try cooktop.
It is free and although does not debug, it can work with several processors and you can see the output right away.
http://www.xmlcooktop.com/[^]
"I will find a new sig someday."
|
|
|
|
|
Ah, thanx
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Hi all,
since days I'm looking for a solution to get the information stored in the <xsd:appinfo> or <xsd:documentation> tag from a known XmlElement (for example got by a XPath selection)... Could anybody give me a hint how I can access to this values in C#?
Here a small XML sample, the related XML Schema and C# sample code:
<?xml version="1.0" encoding="UTF-8"?>
<test:TestData xmlns:test="http://xsd.mytest.com/test.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<test:Collection>
<test:Element Id="1">11.00</test:Element>
</test:Collection>
</test:TestData>
------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema targetNamespace="http://xsd.mytest.com/test.xsd" xmlns:test="http://xsd.mytest.com/test.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
<xsd:element name="TestData" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Collection">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>This is the documentation of the Collection</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Element" default="1.00">
<xsd:complexType>
<xsd:annotation>
<xsd:documentation>This is the documentation of the Element</xsd:documentation>
<xsd:appinfo>
<formula>5.000000 + 3.000000</formula>
</xsd:appinfo>
</xsd:annotation>
<xsd:simpleContent>
<xsd:extension base="test:ElementType">
<xsd:attribute name="Id" type="xsd:int" default="1" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="ElementType">
<xsd:restriction base="xsd:double">
<xsd:minInclusive value="0.100000" />
<xsd:maxInclusive value="10.000000" />
<xsd:pattern value="\d{1,2}.\d{1,6}" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
------------------------------
XmlTextReader tr = new XmlTextReader(sXMLFile);
vr = new XmlValidatingReader(tr);
vr.ValidationType = ValidationType.Schema;
XmlTextReader sr = new XmlTextReader(sSchemaFile);
XmlSchema schema = XmlSchema.Read(sr, new ValidationEventHandler(ValidationHandler));
sr.Close();
vr.Schemas.Add(schema);
vr.ValidationEventHandler += new ValidationEventHandler(ValidationHandler);
doc = new XmlDocument();
doc.Load(vr);
vr.Close();
string selectExpr = "//test:TestData/test:Collection/test:Element";
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("test", "http://xsd.mytest.com/test.xsd");
XmlNode root = doc.DocumentElement;
XmlNode myElementNode = root.SelectSingleNode(selectExpr, nsmgr);
------------------------------
The validation works fine and I really get the error notification, that the value of "Element" is out of range. I also get a valid myElementNode object back. But how can I read the Documentation/AppInfo out of this myElementNode? Is it impossible or am I just too stupid? Do I need to write my own parser for that?
Thanks for your help!
Mirco John
|
|
|
|
|
Hi,
I am using MSXML::IXMLDOMNode::baseName to get the name of the node.
i.e., the name of the following node is "modem".
<modem ID="1.6">
<Number>15400979</Number>
<Interval>5</Interval>
</modem>
Does someone know how to get the attribute of this node, i.e. "1.6"?
Thanks!
|
|
|
|
|
The node "modem" has several child nodes. One of which is the attribute node called "ID" as well as child element nodes called Number and Interval. You also has child text nodes that contain your formating text.
Given that pNode is the pointer to your "modem" node.
// Get Attributes
IXMLDOMNamedNodeMap *AtMap;
hr = pNode->get_attributes(&AtMap);
long atpos,atlen;
hr = AtMap->get_length(&atlen);
IXMLDOMNode *item;
for(atpos=0;atpos<atlen;atpos++)
{
hr =="" atmap-="">get_item(atpos,&item);
hr = item->get_baseName(&txt);
name = txt;
hr = item->get_text(&txt);
data = txt;
}
The above code will step through all of the attribute nodes and give you their base name and text value.
"I will find a new sig someday."
|
|
|
|