|
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
|
|
|
|
|
Not to put to fine a point on it, what is stopping you?
I'm not seeing a question or a problem here, just a task you have to do.
If you are having problems with your code post the problem code and errors and we can help.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
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">
<!-- This unique portion is where I need the help. It almost works in that it prevents me from
giving a child element the parent's key, but it also has the unfortunate side effect of not
allowing me to have duplicate key references in the child elements. How can this be done? -->
<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"/> <!-- This is allowed, since it references a different element than it's parent -->
<!-- This duplicate is currently not allowed even though I want it to be. -->
<Child key="A"/> <!-- This is NOT allowed, because this element is a child of Parent "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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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).
|
|
|
|
|
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;
}
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
Good morning.
I have the following simple XML file.
<?xml version="1.0" standalone="yes"?>
<SHRPT_SITE>
<RECORD>
<Name>Apps (doc)</Name>
<Address>http:
</RECORD>
<RECORD>
<Name>Internet Services Architecture (arch)</Name>
<Address>http:
</RECORD>
<RECORD>
<Name>iServices Customer Self Service (staff)</Name>
<Address>http:
</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
|
|
|
|
|
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.
|
|
|
|
|
|
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>
<!-- ifdef ${_xml_preprocess} -->
<!-- <add key="conString" value="${connectionStringWithPassowrd}"/> -->
<!-- else -->
<add key="conString" value="connection string"/>
<!-- endif -->
</appSettings>
</configuration>
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
Clas,
can you use XSLT 2.0 instead 1.0? (If you can control the XSLT engine you use, then switch to SAXON by M. Kaye, from the web-site, you can also download all you need for .NET reuse.)
If so, <xsl:key ...=""> and the so-called Muenchian method is your friend.
All you need to know you will find here:
http://www.jenitennison.com/xslt/grouping/muenchian.html[^]
Best regards,
Stefan
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
HI,
I HAVE A XML FILE WITH HYPHEN(-) IN SOME ITS ELEMENTS FOR EXAMPLE
<NAME>
<FIRST-NAME>JOHN </FIRST-NAME>
<LAST-NAME>MILLER </LAST-NAME>
<AGE>25 <AGE>
</NAME>
I ALSO HAVE XSD FILE VALIDATING THIS XML FILE AND WHEN I BULKINSERT IT IN MY DATABASE ELEMENT NAMES WITH
HYPHEN ARE NOT INSERTING <FIRST-NAME>JOHN </FIRST-NAME> , <LAST-NAME>MILLER </LAST-NAME>
WHERE AS NON-HYPHEN ELEMENTS <AGE>25 <AGE> INSERTED FINE.
HOW CAN I VALIDTE THE HYPHENATED ELEMENTS WITH MY XSD AND THEN INSERT INTO DATABASE. PLS HELP
sai krishna
|
|
|
|