 |
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers, Chris Maunder
The Code Project Co-founder Microsoft C++ MVP
|
| Sign In·View Thread·PermaLink | 4.40/5 (2 votes) |
|
|
|
 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers, Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
| Sign In·View Thread·PermaLink | 4.40/5 (2 votes) |
|
|
|
 |
|
 |
Given the xml snippet below, I am trying to read the Company value. I have other code which will obtain the Network Policy Zone and the Default Gateway of a given system. Using these two values, zone first, then dfgw, I need to get the Company value which correspondes so it can be set as an environment variable in a remote windows system.
Here's my mess of code, and I'm afraid it is a mess because I've been trying different things:
Sub ReadXML() Dim attrValue, child1, child2, gChild1 getZone() WScript.Echo "Zone is: " & zone Set xDoc = CreateObject("Microsoft.XMLDOM") xDoc.async = False xDoc.load ("company.xml") Set Root = xDoc.documentElement Set NodeList = Root.getElementsByTagName(zone) Set child1 = xDoc.documentElement.firstChild Set child2 = child1.nextSibling Set gChild1 = child1.firstChild Do Until attrValue <> dfgw attrValue = xDoc.GetAttrValue("DFGW") WScript.Echo("DFGW Attribute Value is: " & attrValue) xDoc.nextSibling Loop company = gChild1.nodeValue("Company") WScript.Echo("Company Attribute Value is: " & attrValue) WScript.Echo("Default Gateway: " & dfgw) SetCompany(company) End Sub
Here's the XML I'm trying to read:
="1.0" - <ZoneList> - <Zone0> - <DFGW> "192.168.25.1" <Company>"CPC"</Company> </DFGW> - <DFGW> "142.101.230.1" <Company>"Test Company"</Company> </DFGW> - <DFGW> "" <Company>""</Company> </DFGW> - <DFGW> "" <Company>""</Company> </DFGW> - <DFGW> "" <Company>""</Company> </DFGW> </Zone0> - <Zone1>
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
i have xml file iam having c# application i need to 1-read xml file in c# abd pass it as parameter to sql server store procedure (parameter type xml) 2- use procedure have xml parameter to insert data into table
md_refay
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Firstly, if anyone could send me a link that explains everything that is allowed in XSD xpath expressions, I would be very grateful. I have searched for hours, and still have no idea what subset of xpath is allowed for either the selector or the field nodes. Great thanks to anyone who knows where I can find some documentation on this feature of xsd.
On to my problem... I am attempting to have an element, "parent", that contains a key attribute called "key". Every such element may have 0 or more child elements, called "Child", such that they contain a keyref attribute called "key" as well. I am wondering if there is a way to enforce through the XSD that the value of "key" for the child elements cannot be equivalent to the value of "key" for the parent node. So, for example:
<!-- XSD File -->
<xsd:element name="Example" type="ExampleType"> <xsd:key name="ParentKey"> <xsd:selector xpath="Parent"/> <xsd:field xpath="@key" /> </xsd:key> <xsd:keyref name="ChildKeyRef" refer="ParentKey"> <xsd:selector xpath="Parent/Child"/> <xsd:field xpath="@key" /> </xsd:keyref> </xsd:element>
<xsd:complexType name="ExampleType"> <xsd:sequence> <xsd:element name="Parent" type="ParentType" maxOccurs="unbounded"> <!----> <xsd:unique name="UniqueKeyRef"> <xsd:selector xpath=".|Child"/> <xsd:field xpath="@key" /> </xsd:unique> </xsd:element> </xsd:sequence> </xsd:complexType>
<xsd:complexType name="ParentType"> <xsd:attribute name="key" type="xsd:String" use="required"/> <xsd:sequence> <xsd:element name="Child" type="ChildType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType>
<xsd:complexType name="ChildType"> <xsd:attribute name="key" type="xsd:String" use="required"/> </xsd:complexType> <-- XML File -->
<Example> <Parent key="A"> <Child key="B"/> <Child key="B"/> <!----> <!----> <Child key="A"/> <!----> </Parent> <Parent key="B"/> </Example> Hopefully this example has clearly illustrated my desire. Any number of children of Parent "A" can reference any other parent, including multiple children referencing the same parent (such as the two child elements referencing parent "B" in my example). Is there some way to rework my unique constraint, or by adding another constraint, such that these duplicates are allowed? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
modified on Tuesday, November 3, 2009 10:19 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Not sure if this answers your question ( I didn't read it all ), but I've always used this[^] when I need to do XSLT/XPath stuff.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
The Essential XML Quick Reference[^] is an excellent (and free) XML (+ XSD + XPath + XSLT) reference.
On page 349, it defines the available XPath selectors (I'd copy them here, but it disallows copying - grrrr).
However, I don't think you can do what you want with the 'unique' relation. The correctness 'uniqueness' set would be '..|.' using the Child element as the context node. But you can't do that with XML Schemas.
Using the Parent as context node, there's no way to define the uniqueness set, I don't think, as there are n sets, where n==number of Child nodes.
However - using Schematron[^], you can validate this rule using this Schema:
<schema xmlns="http://www.ascc.net/xml/schematron" > <pattern name="Check CHild/Parent keys"> <rule context="Child"> <assert test="@key!=../@key">Child key should differ from Parent key.</assert> <report test="@name">Child key should differ from Parent key.</report> </rule> </pattern> </schema>
This should be used in addition to a schema describing the basic structure of the XML. Using xmllint (which comes with libxml2), I can confirm that this Schematron schema meets your requirements.
XML files can be validated against Schematron schemas using an XSLT processor, so even if your XML parser doesn't have Schematron support, you can still use Schematron.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Yeah, that is what I was afraid of... I know I could do it using XSD 1.1 or, as you suggested, Schematron, but validating against either of those options isn't well supported (at least as far as I can tell) in Java or C. I actually tried what you suggested with the parent element, saw it wasn't supported, and figured that there must just be some other well-hidden way to go about it. I don't want to have a second definition file, so embedded Schematron may be the answer right now (if I can figure out how to validate against it), or I could just wait until next April when the XSD 1.1 specification is finalized. Anyway, thank you very much for the help!
Sounds like somebody's got a case of the Mondays
-Jeff
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Schematron is supported by libxml2, so (therefore) is accessible to C or C++ or anything else that exposes that part of libxml2 through a binding.
The Schematron website describes the steps needed to perform Schaematron validation:
xslt -stylesheet iso_dsdl_include.xsl theSchema.sch > theSchema1.sch xslt -stylesheet iso_abstract_expand.xsl theSchema1.sch > theSchema2.sch xslt -stylesheet iso_svrl_for_xsltn.xsl theSchema2.sch > theSchema.xsl xslt -stylesheet theSchema.xsl myDocument.xml > myResult.xml
Basically, generate an XSLT file from your Schematron schema (the first three steps). Then process the input XML file using your XSLT processor and the generated XSLT file to output something that tells you if the XML is valid per the Schematron schema.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am using c# serialisation to write some xml. For some reason the output is not necessarily written in the order it appears in the code.
How can I order the elements?
For example:
[Serializable] public class Request { [XmlElement("Type")] public string Type { get; set; }
[XmlElement("Id")] public int Id { get; set; } }
Would write
<Request> <Id>1</Id> <Type>Get</Type> </Request>
(Note this example is very simplified and doesn't actually write it wrongly).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Fixed it.
It turns out, fields are serialised before properties and my code was actually like this:
[Serializable] public class Request { [XmlElement("Type")] public string Type { get; set; }
[XmlElement("Id")] public int Id; }
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have just been successfull at generating an element centric xml query using linq to my sqlserver database. Can someone show me an example how to do it to generate an attribute centric result?
I also am able to save the results to a file on my c drive but need to save it to an xml file in my project.
Thank you in advance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am generating a Excel Sheet(XML SpraedSheet) through XSLT transform.How to password protect the XML SpreadSheet in XSLT.
Is there is any tag to password Protect?
Is there is any other solutions to password protect the XML Spreadsheet?
Best Regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
It's as if you understand XSLT, and yet somehow have no idea what XML is. How is that possible ?
XML is a string. You can write external code to encode the entire string ( meaning it won't be XML anymore ), or to encode the contents of the nodes. You'd then need corresponding code to decode the information. You can invent a 'password protect tag', but it's plainly not going to alter the fact that all you have is a plain text file.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Good morning.
I am populating a datagridview with a dataset from an XML file.
I now want to write some code to delete a row on the datagridview to simulate a user clicking on the row and hitting the Delete button.
Any ideas on how to accomplish this?
Thank you, WHEELS
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Good morning.
I have the following simple XML file.
="1.0" ="yes" <SHRPT_SITE> <RECORD> <Name>Apps (doc)</Name> <Address>http://unumtfsprod/sites/IServices/Apps/Forms/AllItems.aspx</Address> </RECORD> <RECORD> <Name>Internet Services Architecture (arch)</Name> <Address>http://teamspace/sites/iservices/architecture/default.aspx</Address> </RECORD> <RECORD> <Name>iServices Customer Self Service (staff)</Name> <Address>http://teamspace/sites/isgcrm/custselfsvc/default.aspx</Address> </RECORD> </SHRPT_SITE>
I want the user to be able to click a (favorites) button and be able to add a site name and URL to the file. What would be the best code approach to accomplish this?
Thank you, WHEELS
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Use an XmlDocument to create a new record, and then append it to the shrpt_site node.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Is it possible to call a comand line program from within an Xml File Preprocessor. I have a connection string that is encrypted in a settings file and i want to decrypt it before assigning it to the conString value
<configuration> <appSettings> <!----> <!----> <!----> <add key="conString" value="connection string"/> <!----> </appSettings> </configuration>
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
No. You should write code to decrypt it in a class and use that to access the values.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi.
How can I group values in "Type" ( xmldatasource - fill dropdownlist with distinct values ) ?
XSL:
<?xml version="1.0"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msxsl="urn:schemas-microsoft-com:xslt" > <xsl:strip-space elements="*"/> <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" standalone="yes" /> <xsl:template match="/"> <xsl:for-each select="dataroot"> <xsl:element name="dataroot"> <xsl:for-each select="Table_A"> <xsl:element name="Table_A"> <xsl:attribute name="Type"> <xsl:value-of select="Type"/> </xsl:attribute> </xsl:element> </xsl:for-each> </xsl:element> </xsl:for-each> </xsl:template> </xsl:transform>
XML: <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2009-10-21T09:21:31"> <Table_A> <ID_I>100085004</ID_I> <Type>GPS</Type> <Value>0</Value> <SDD_Date>1829-06-12T00:00:00</SDD_Date> </Table_A> </dataroot>
Thanks in advance !!
modified on Friday, October 23, 2009 3:43 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello community,
i am new user and its my first question that i seek an answer or some sort of answer that will help me with my work so please don't judge me 
My problem is that i made html page and on that page i have form in witch i insert email/password.I want those informations to be inserted into Xml file file witch i already have in my project.I want this problem to be solved with javascript or jquery.(server environment not client if that is possible).
So if anyone is interested in solving my problem it will be from big help to me.
Thanks.
modified on Monday, October 19, 2009 8:16 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
live4u wrote: I want this problem to be solved with javascript or jquery.(server environment not client if that is possible).
Um... I know you're new and all, but you just asked a dumb question. You want to use client side code, but you want it to run on the server ? How does that make sense ?
To manipulate XML, there's almost certainly a DOM implimentation in the framework you're using, but if you want specific code, the ASP.NET forum for ASP.NET or web dev for any other web platform, is the best place to ask this. Although it relates to XML, it's hard to know how to answer based on what you said. XmlDocument class if you're using .NET, otherwise I don't know. But, you can't use javascript or jquery ( which is just a javascript library, it's not a language ) on the server, nor should you want to.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi am a LAMP developer and our team are about to embark on a version 2 of a web based application, with an upgrade of client tier to AJAX. For client-server communication we have narrowed down the options to XML and JSON was wondering what are the benefits and drawbacks of both. Right now am leaning towards JSON?
Regards
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
As opposed to embedding an image within a Microsoft Word 2007 document, I have been looking for the possibility of using XML to link to another location on the network where the image files would be stored locally.
Is this possible? If so, would anyone be able to help by pointing me in the direction of learning more knowledge on this subject?
Any and all help is greatly appreciated
jsquires
modified on Friday, October 16, 2009 10:57 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |