Finally, I could create the desired xsd to valid the xml. I truly appreciate your great help. Thanks a lot. :) Prakash
tprakash
Posts
-
Detect Invalid sequence of tag in XML document using schema. -
Detect Invalid sequence of tag in XML document using schema.Actually, we have two applications, one generates the xml, while other application consume the xml. The format of xml is defined by my management team. We have different clients using that applications(single only or both). And it is our management team decision not to change the format of the xml file. We just donot want to mesh up with that now. Otherwise, it is ok.
-
Detect Invalid sequence of tag in XML document using schema.I think the solution (b) works perfectly in cases where we have normal xml node. What about if the a child xml node contains parent xml node recursively? Taken the above case, what if Permissions node in turn contains the Roles ? Since we cannot use ref attribute, how to refer the Roles node in the above xsd? Thanks Prakash
-
Detect Invalid sequence of tag in XML document using schema.a) The XML file I am validating is from my clients. They cannot bear any change modification on that xml because it is being used by many others clients. They already working on the format of that xml. If I add an xml namespace in the XML file, all of my clients have to change their logic to read the modified XML file. What I can do is to write the xsd file to validate that XML file. It wouldn't have been problem if I could use namespace. I think your answer (b) will work for me. Thank your great help. Prakash
-
Detect Invalid sequence of tag in XML document using schema.Hi, As you said we cannot use 'ref' attribute in xsd without using some level of xml namespace. Can we write a schema file (xsd) to valid the xml without having xmlns? Is there any other alternative to valid the xml without having xmlns? I mean, can we write xsd to valid the following xml? <?xml version="1.0" encoding="utf-8"?> <Roles> <Role> <Permissions> <Permission>Reader</Permission> </Permissions> </Role> <Permissions> <Permission>Reader</Permission> </Permissions> </Roles> Thanks. Prakash
-
Validate Xml without using xmlnsHi, I have the xml document like, <?xml version="1.0" encoding="utf-8"?> <Drive> <folders> <folder name="f1"> </folder> <folder name="f2"> </folder> </folders> </Drive> Please notice that there is no xmlns used and I cannot used xmlns in this xml document. I have problem creating schema (.xsd) file to validate this xml document. My schema is like <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.tempuri.com/temp" elementFormDefault="qualified"> <element name="Drive"> <complexType> <sequence> <element ref="folders" minOccurs="0" maxOccurs="1"/> </sequence> </complexType> </element> <element name ="folders"> <complexType> <sequence minOccurs ="0" maxOccurs ="unbounded"> <element ref ="folder"/> </sequence> </complexType> </element> <element name ="folder"> <complexType> <sequence> <element ref ="folders" minOccurs ="0" maxOccurs="1" /> </sequence> <attribute name ="name" type="string" /> </complexType> </element> </schema> But the ref attribute is not working. ie the attribute 'folders' cannot reference the element 'folders'. I am using VS2008 to create/edit xsd file. VS2008 shows warning message "The 'http://www.w3.org/2001/XMLSchema:folders' element is not declared.". The same exception occurs if I run my c# program to valid the xml. Could you please suggest me how to refernce element using ref attribute without using namespace? Is there any other workaround? Thanks. Prakash
-
Detect Invalid sequence of tag in XML document using schema.Thank you very much. It worked perfectly :) .
-
Detect Invalid sequence of tag in XML document using schema.I have xml tags as below. file1.xml <Roles> <Role> <Permissions>Admin<Permissions/> <Permissions>Reader<Permissions/> </Role> </Roles> Here is my XSD to validate above xml myXSD.xsd <element name="Roles"> <complexType> <sequence> <element ref="Role"> </sequence> </complexType> </element> <element name ="Role"> <complexType> <sequence> <element ref ="Permissions" minOccurs="1" maxOccurs="unbounded" /> </sequence> </complexType> </element> <element name ="Permissions"> <complexType> <sequence> <element name ="Permission" type="string" /> </sequence/> </complexType/> </element/> This XSD validation works fine in normal case. If I change the xml file as below. file2.xml <Roles> <Role> <Permissions>Admin<Permissions/> <Permissions>Reader<Permissions/> </Role> <Permissions>Reader<Permissions/> </Roles> ie. I inserted the <Permissions> immediately after the <Roles> parent node. This is invalid in my case. I want to enforce that <Permissions> node always comes inside the <Role> node but not <Roles> node. I want to detect this such case using XSD validation. Could you please suggest me how to write the correct XSD schema to invalidate file2.xml? Thanks in advance Prakash
-
Diable Print and Export button in crystal reportDear Friends I have use asp.net 2.0 page to display report using CrystalReportViewer. The reports are viewed by many users. Now I want the print button in the tool bar of crystal report to be disable so that user could not print the report. Similary I want to disable export button also. Please give me some hints Thank You All Prakash
-
Reading Non-Ole File PropertyWe are trying to read Non-Ole File Properties (eg office 2007) using dsofile.dll. We can easily read properties of both Ole(doc file 97,2003) and non-ole(office 2007) using dsofile.dll(com dll). We did not use dsofile com dll because it has to be registered and take reference in the calling C# project. Actually we re-wrote our own dll using visual c++.net. The main interface for reading ole file property is IStoragePropertySet object. Here is the code snippets // If the file is an OLE Storage DocFile... if(StgIsStorageFile(m_bstrFileName)==S_OK) { IStorage *pStorage = NULL; IPropertySetStorage *pPropSetStg = NULL; HRESULT hr; // Open the document as an OLE compound document. hr = ::StgOpenStorage(wcFilename, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, NULL, 0, &pStorage); } else { //How to get non-ole file properties } As I showed the code snippets, there is no problem in getting ole-file properties. What we are struck in is getting non-ole file property. Here is the code snippets from the original source code of dsofile com dll.
// If the file is an OLE Storage DocFile...
_if (StgIsStorageFile(m_bstrFileName) == S_OK)
{
// Get the data from IStorage...
hr = StgOpenStorage(m_bstrFileName, NULL, dwOpenMode, NULL, 0, &m_pStorage);// If we failed to gain write access, try to just read access if caller allows // it. This function will open the OLE file in transacted read mode, which // covers cases where the file is in use or is on a read-only share. We can't // save after the open so we force the read-only flag on... if (((hr == STG\_E\_ACCESSDENIED) || (hr == STG\_E\_SHAREVIOLATION)) && (m\_dwFlags & dsoOptionOpenReadOnlyIfNoWriteAccess)) { m\_fReadOnly = TRUE; hr = StgOpenStorage(m\_bstrFileName, NULL, (STGM\_READ | STGM\_TRANSACTED | STGM\_SHARE\_DENY\_NONE), NULL, 0, &m\_pStorage); } // If we are lucky, we have a storage to read from, so ask OLE to open the // associated property set for the file and return the IPSS iface... if (SUCCEEDED(hr)) { hr = m\_pStorage->QueryInterface(IID\_IPropertySetStorage, (void\*\*)&m\_pPropSetStg); }_ } **else if ((m\_dwFlags & dsoOptionOnlyOpenOLEFiles) != dsoOptionOnlyOpenOLEFiles) { // If caller would like non-OLE property sets, we can try to provide them. There // are two types: (1) explicit metadata handlers registered by file type; or (2) // NTFS 5.0+ pro**
-
Datagrid binding problem: undefinedYeah."undefined" is displayed on post back. tprakash
-
Datagrid binding problem: undefinedI have datagrid on asp.net page.On page load the page fetch data from mssql database and bind it to the datagrid. There is one unusual problem.ie, "undefined" is displayed on all the rows and columns of the datagrid occassionally. Please give me some hint to solve this panic problem. Thanks for your valualbe information. tprkash
-
Assigning permission for aspnet user to web directory folderI have a web application. It has a folder named "data" under the project dir. My web application creates files in "data" folder. I know in order to create file in "data" folder, aspnet should have permission. For that we have to go to property of the web application folder. There under the tab Security ,press Add button.A form appears Write aspnet to the textbox and press ok. Then press checkbox to give full control to aspnet user. It works fine when developing. My problem is : when I create a web installation package of that application and install it to my client computer, I have to repeat above procedure. Is there any way to assign aspnet user full control of the folder "data" ? I mean without repeating above procedure, could I dynamically/programmatically assign full access over the "data" folder to aspnet user? :) Any information is highly appreciated? Thanks for you valuable comments. prakash
-
Take some action when message is received by client in webformI have written soap server and soap client using SoapSender and SoapReceiver class of WSE2.0. The soap server in console application while the soap client is in web application. The client requests the server. When the server replies some message to the client. This message is received in the client portion ie in the function Receive. protected override void Receive(SoapEnvelope env) { } Now the problem is, if i write some code inside the Receive function as protected override void Receive(SoapEnvelope env) { //some code to extract message from the soapenvelope WewForm1 wf=new WebForm1(); wr.Response.Redirect("WebForm2.aspx"); } It won't redirect to page WebForm2.aspx. My objective is to take some action (either redirect to another page or just display the message received in the current page) when the message is received. Could somebody tell me how to do this? Thanks in advance. tandukar
-
Regarding SoapSender and SoapReceiverI had written server and client programs in c# using SoapSender and SoapReceiver class. I used soap.tcp://localhost:8080/myservice in Uri. It works well in localhost. Now please any body help me to connect two machines. By What value should I replace localhost? in both server and client part. Thanks in advance. prakash