|
|
Hi!
I need to select certain nodes that DON't have specific subnodes, i.e.
Select all nodex x/y where there is no subnode x/y/a or x/y/b
Example:
<x>
<y> <!-- select this one -->
<bla>blup</bla>
</y>
<y> <!-- this one as well-->
<foo>test</foo>
</y>
<y> <!-- this one not: x\y\a -->
<a>bla</a>
</y>
<y> <!-- this one not: x\y\b -->
<b>bla</b>
</y>
</x>
I'd appretiate all suggestions. Thanks in advance!
Regards,
Andre Loker
|
|
|
|
|
Hi Andre. Here's one approach - using a for-each to select only those x/y nodes that don't have a child a or child b node.
<?xml version='1.0' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<xsl:for-each select="x/y[not ((descendant::a) or (descendant::b))]">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet> I hope that helps.
|
|
|
|
|
Yes, it works great, thanks a lot!
Regards,
Andre Loker
|
|
|
|
|
I'm reading an XML input file using SAX, if I find that some infor is missing from that file (while I'm parsing it), I want to go to another XML file and see if the info is there (again parsing using sax).
It seems to be working after a fashion, but I keep getting access violations in MSXML4. Can you have more than one reader active at a time parsing more than one file using MSXML?
|
|
|
|
|
I have a commemerce server site and an asp site... i want to exchange xml between the two sites but i need to use soap to get through the firewall... any suggestions on where to start... im new to soap
|
|
|
|
|
Hey All,
I have a client built using VC++ running on Windows which sends Soap messages to a web service deployed on Tomcat that uses Axis.
The client is being localized in Japanese as well.
Here comes the problem:
When user enters a lot of doube-byte Japanese characters in the client UI then error occurs while sending the soap request. The error occurs when Finished() is called. This problem does not occur in following cases:
- if user enters lesser number of characters as input
- in English version.
I am using InitWithComposer() method of SoapSerializer30 to compose the soap since the message may contain attachmetns too. DimeComposer30 is used in this method.
Also, I noticed if I use Init() method instead of InitWithComposer. This problem does not occur
Can somebody tell me where the problem is? The code is also listed below for reference.
Soap toolkit 3.0 is being used and UTF-8 encoding is used in XML.
The error returned is given below.
-------------------------------------------------------------
- Exception:
AxisFault
faultCode: {http://xml.apache.org/axis/}Server.userException
faultString: java.io.UTFDataFormatException: Expected byte 3 of 3-byte UTF-8 sequence.
faultActor: null
faultDetail:
stackTrace: java.io.UTFDataFormatException: Expected byte 3 of 3-byte UTF-8 sequence.
at org.apache.xerces.impl.io.UTF8Reader.expectedByte(Unknown Source)
at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.scanContent(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanContent(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:232)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:546)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:304)
.
.
.
Code:
-------------------------------------
HRESULT hr;
ISoapSerializerPtr pSerializer;
ISoapReaderPtr pReader;
hr = pSerializer.CreateInstance(__uuidof(SoapSerializer30));
if(FAILED(hr))
return FALSE;
IMessageComposerPtr Composer;
hr = Composer.CreateInstance(__uuidof(DimeComposer30));
if(FAILED(hr))
return FALSE;
pSerializer->InitWithComposer((IUnknown*)mpConnector->InputStream,Composer);
pSerializer->StartEnvelope("","http://schemas.xmlsoap.org/soap/encoding","");
pSerializer->SoapAttribute("xsi","",
"http://www.w3.org/2001/XMLSchema-instance","xmlns");
pSerializer->SoapAttribute("xsd","","http://www.w3.org/2001/XMLSchema","xmlns");
pSerializer->StartBody("");
pSerializer->StartElement("CheckIn", "",
"http://schemas.xmlsoap.org/soap/encoding/", "ns1");
pSerializer->SoapAttribute("ns1" ,"","urn:OrionService","xmlns");
pSerializer->StartElement("command",_bstr_t(),_bstr_t(),_bstr_t());
pSerializer->SoapAttribute("ns2","",
"http://schemas.xmlsoap.org/soap/encoding/","xmlns");
pSerializer->SoapAttribute("type","","ns2:Array","xsi");
//Format the command string
CFormatter ObjFormat;
if(_tcscmp(pidlData->szTitle, ""))
{
_stprintf(str,"-dis 1 dm_object title C \"%s\" U",pidlData->szTitle);
ObjFormat.AddText(str);
}
//Add the command string array to soap request
TCHAR strID[1000];
_stprintf(strID,"xsd:string[%d]",ObjFormat.GetItemCount());
pSerializer->SoapAttribute("arrayType","",strID,"ns2");
TCHAR *token;
token = _tcstok( ObjFormat.GetString(), "\n");
while( token != NULL )
{
pSerializer->StartElement("item",_bstr_t(),_bstr_t(),_bstr_t());
pSerializer->SoapAttribute("type",_bstr_t(),"xsd:string","xsi");
pSerializer->WriteString(token);
pSerializer->EndElement();
token = _tcstok( NULL, "\n" );
}
pSerializer->EndElement();
//Add file original file names to soap request
pSerializer->StartElement("fileName",_bstr_t(),_bstr_t(),_bstr_t());
pSerializer->SoapAttribute("ns2","",
"http://schemas.xmlsoap.org/soap/encoding/","xmlns");
pSerializer->SoapAttribute("type","","ns2:Array","xsi");
if (cDocumentType == 'R') // registerd
_stprintf(strID,"xsd:string[%d]",0);
else if (cDocumentType == 'S') // storted
_stprintf(strID,"xsd:string[%d]",iDocCount);
else if (cDocumentType == 'M') // multisheet
_stprintf(strID,"xsd:string[%d]",iDocCount);
pSerializer->SoapAttribute("arrayType","",strID,"ns2");
lpFiles= lpFilesList;
if (cDocumentType == 'S') // storted
{
for(i = 0;i<idoccount;i++)
{
="" pserializer-="">StartElement("item",_bstr_t(),_bstr_t(),_bstr_t());
pSerializer->SoapAttribute("type","","xsd:string","xsi");
pSerializer->WriteString((lpFiles->szFileName+lpFiles->iOffset));
lpFiles= lpFiles->pNext;
pSerializer->EndElement();
}
}
pSerializer->EndElement();
//Add files array to soaprequest
pSerializer->StartElement("file",_bstr_t(),_bstr_t(),_bstr_t());
pSerializer->SoapAttribute("soapenc","",
"http://schemas.xmlsoap.org/soap/encoding/","xmlns");
pSerializer->SoapAttribute("type","","soapenc:Array","xsi");
_stprintf(strID,"ns1:DataHandler[%d]",iDocCount);
pSerializer->SoapAttribute("arrayType","",strID,"soapenc");
//DebugBreak();
FileAttach = new IFileAttachmentPtr[iDocCount];
for(i=0;i<idoccount;i++)
{
="" fileattach[i].createinstance(__uuidof(fileattachment30));
="" pserializer-="">StartElement("item",_bstr_t(),_bstr_t(),_bstr_t());
FileAttach[i]->FileName = sFileName[i];
pSerializer->AddAttachmentAndReference(FileAttach[i]);
pSerializer->EndElement();
}
pSerializer->EndElement();
//Locale
pSerializer->StartElement("Locale",_bstr_t(),_bstr_t(),_bstr_t());
pSerializer->SoapAttribute("type","","xsd:string","xsi");
pSerializer->WriteString(msLocale);
pSerializer->EndElement();
pSerializer->EndElement();
pSerializer->EndBody();
pSerializer->EndEnvelope();
pSerializer->Finished();
Hope to see the response soon.
Thanks
Rohit Sethi
|
|
|
|
|
my web service returns Xmlnode. I want to read attribute name and populate Dropdownlist.
Here is what I have been trying .. nothing seems to work ... any suggestions please
Dim SearchResult As MyWebservie = ar.AsyncState
Dim node As XmlNode = TicketSearchResult.EndGetEventList(ar)
//Dim ReadNode As XmlNode = node.SelectSingleNode("DATA") //
Dim Reader As New XmlNodeReader(ReadNode)
//Dim mydataset As New DataSet
//mydataset.ReadXml(Reader)
//Dim resultNodes As XmlNodeList = node.SelectNodes("raw") //node i need attributs from this
// Dim iCount As Integer = 0
// Dim aNode As XmlNode
// For Each aNode In resultNodes
// DropDwonLis1.Item.Add /// Console.WriteLine("Node {0} value: {1}", ++iCount, aNode.InnerText)
'ToDo: Unsupported operator
'ToDo: ++ operator not supported within expressions
Next aNode
here is what web service returns
- <root>
- <methodinfo>
<channelname>Search
<methodname>MyWebservice
<parameters>?APP_ID=1
<processtime type="milliseconds">453.1366
-
<row thisid="2" thisname="Beach ST=" "="">
<row thisid="1" thisname="Playhouse" st="GA">
<row thisid="3" thisname="Arena" st="MD">
<row thisid="4" thisname="Park" st="CA">
I want THISNAME IN DROPDOWNLIST and THISID as option Value in dropdownlist
|
|
|
|
|
Hi,
I couldn't read all your message as the XML is not being displayed as the page is processing the < > tags.
To read attributes of a node, use the following:
XmlNode thisNameNode = aNode.attributes.getNamedItem("thisname");
XmlNode thisIdNode = aNode.attributes.getNamedItem("thisid");
if (thisNameNode != null && thisIdNode != null)
{
string thisNameValue = thisNameNode.text;
string thisIdValue = thisIdNode.text;
System.Web.UI.WebControls.ListItem item = new ListItem(thisNameValue, thisIdValue);
DropDwonLis1.Items.Add(item);
}
Hope this helps,
Andy
|
|
|
|
|
I have some xml document describing our database.
I have an element <value>
in side of that document for empty element, but
when I parse it using DOM in VB
For Each rowElement In xmlDoc.documentElement.childnodes
str_content = rowElement.childnodes(0).nodeValue
Next
when I have NULL in the element I have application error
said "NULL is not properly used". I tried to filter the
NULL by
If rowElement.childnodes(0).nodeValue = NULL then
....
however, vb doesn't recognize this null
do you think i should not use
for empty element in the first place?
there is another solution?
Thanks for help
shin
|
|
|
|
|
How to load XslTransform from data base or just from string? I don't want to load it from file, I keep all the XSL documents in data base and I just want to load them from record.
|
|
|
|
|
Use the Document objects loadXML( string) method
doc.loadXML( string_from_database)
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Apparently I'm having a problem with MS XML libraries.
We're posting an XML doc to an external site which parses the doc and provides an HTTP Response Number.
We also need the XML to be re-posted from the external site to another page of ours and have the XML saved as a doc. In standard ASP we're doing this as follows...
[code]
<%
strABBXMLFile = Server.MapPath("/spider/abb/abbn/" & Day(Now) & "-" & Month(Now) & "-" & Year(Now) & "_" & Hour(Now) & Minute(Now) & "_standardAbbreviation.xml")
Set doc = Server.CreateObject("Msxml2.DOMDocument.4.0")
doc.load(Request)
doc.save(strABBXMLFile)
%>
[/code]
The problem we have is with entity declaration and tags. With entity declarations or a DocType in the XML none of the MS XML libraries can save the XML document. If the <doctype> is removed, they xml is saved fine. Can anyone provide any further information on this issue, or if there's a work-around for it? Or do the .Net XML libraries cope with entity declarations and doctype tags, and can anyone provide any pointers to dot-netting the above?
All help much appreciated, as well as advice.
Cheers!
Rhys
"When one burns one's bridges, what a very nice fire it makes" -- Dylan Thomas
"As to marriage or celibacy, let a man take the course he will. He will be sure to repent" -- Socrates
"Doh!" -- Homer Simpson
|
|
|
|
|
I send to the xsl string parameter as
strPathFiles = "C:\Documents and Settings.."
args.AddParam("strPathFiles", "", strPathFiles)
Me.myXslSrcTransform.Transform(oXPathNav, args, swContent, Nothing)
'(This is vb .Net code)
I want to use it in <IMG> tag as src attribute:
<IMG>
<xsl:attribute name="src">
<xsl:value-of select="$strPathFiles"/>myDir\myFile.gif<xsl:text/>
</xsl:attribute>
</IMG>
but the xsl parses it to -
"C&#58;&#92;Documents&#32;and&#32;Settings"
What string do I need to send to the xsl that will not be parsed,
or else, -
How can I force the xsl to not parse the string?
Thanks.
Atara
|
|
|
|
|
Maybe the disbale-output-escaping Attribute in xsl:value-of will help.
|
|
|
|
|
Thanks. I will try it
Atara
|
|
|
|
|
I tried
<xsl:param name="strPathFiles" /> <!-- Get its value from the application. -->
<xsl:variable name="strPathU" ><xsl:value-of select="$strPathFiles" disable-output-escaping="yes" /></xsl:variable>
<IMG border='0' width='19' height='18' align='middle' >
<xsl:attribute name="src">
<xsl:value-of select="$strPathU" disable-output-escaping="yes" />links_files\ref2_books.gif<xsl:text/>
</xsl:attribute>
</IMG><xsl:text/>
<p><xsl:value-of select="$strPathU" disable-output-escaping="yes" />myDir\myFile.gif<xsl:text/></p>
In the <P> , the string is exactly as I want it, but in the <IMG> I still get -
"C&#58;&#92;Documents&#32;and&#32;Settings"
Maybe disable-output-escaping has no effect in <xsl:attribute> because it might cause illegal-xml .
Any other suggestions?
Thanks,
Atara
|
|
|
|
|
I just tried to reproduce your problem, but I get <img src="C:\Documents and Settings..myDir\myFile.gif"></img> even without using "disable-output-escaping".
Do you use a special encoding or xsl:output?
|
|
|
|
|
In the xsl file, I use
<xsl:output method="html">
It all started when I discovered that I have a problem when my path contains
special unicode chars, so I tried to replace all non-Alpha-Numeric characters
with their corresponding html entities.
so in VB .Net I get the unicodePath, I replace the characters I want,
and I send it as parameters to the XSL.
If there is a simpler way, I would like to know about it...
Thanks
Atara
|
|
|
|
|
(sorry, I forgot to set the Do not treat <'s as HTML tags)
In the xsl file, I use
<xsl:output method="html" />
Atara
|
|
|
|
|
I have an ASP.NET project with a String with XML in it. The XML was created from a DataSet using ds.GetXml(). Now, I want to put the contents of the 2nd column into a listbox. How can I read the string to extract the data to put it into a dataset or directly into the listbox?
Tor Solvang
|
|
|
|
|
Hi Tor,
The best way is to load the XML string into an XML document and then use XPath to retrieve the information (nodes) you want, e.g.
XmlDocument xmlReceive = new XmlDocument();
if (xmlReceive != null)
{
xmlReceive.LoadXml(xmlStringFromDataSet);
XmlNodeList collResults = xmlReceive.SelectNodes("/your/xml/tag/path/here");
if (collResults != null && collResults.Count > 0)
{
for(int i=0; i < collResults.Count; i++)
{
XmlNode nodeResult = collResults[i];
if (nodeResult != null)
{
lstBox1.Items.Add(nodeResult.text);
}
}
}
}
Replace the XPath above with the one you require.
Hope this helps,
Andy
|
|
|
|
|
you have not actually given us your REAL code - as the template would not work "<br>" in the template should be "<br/>".
if you show us the actual code we might be able to help.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Oh, sorry. I cleaned it up a little bit before posting and that small mistake slipped in. However, I already found a solution for the problem. The following template does the trick for me:
<xsl:template name="convertlinebreaks">
<xsl:param name="text"/>
<xsl:choose>
<xsl:when test="contains($text,'&#xA;')">
<xsl:value-of select="substring-before($text,'&#xA;')"/>
<br/>
<xsl:call-template name="convertlinebreaks">
<xsl:with-param name="text">
<xsl:value-of select="substring(substring-after($text,'&#xA;'), 2, string-length(substring-after($text,'&#xA;')))"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
But I'd still like to know how this could be implemented using the translate() function.
|
|
|
|
|
In my XSL document I need to output some HTML if a node exists and it's not empty. I've tried testing it like this but it's not working:
<xsl:if test="'{Main/Whatever}' != ''"><br />
...<br />
</xsl:if>
It always goes into the if , no matter what. What's the solution?
Thanks,
Alvaro
Give a man a fish, he owes you one fish. Teach a man to fish, you give up your monopoly on fisheries.
|
|
|
|
|