Search Results

Search found 17914 results on 717 pages for 'xml schema'.

Page 5/717 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • XML deserialization doubling up on entities

    - by Nathan Loding
    I have an XML file that I am attempting to deserialize into it's respective objects. It works great on most of these objects, except for one item that is being doubled up on. Here's the relevant portion of the XML: <Clients> <Client Name="My Company" SiteID="1" GUID="xxx-xxx-xxx-xxx"> <Reports> <Report Name="First Report" Path="/Custom/FirstReport"> <Generate>true</Generate> </Report> </Reports> </Client> </Clients> "Clients" is a List<Client> object. Each Client object has a List<Report> object within it. The issue is that when this XML is deserialized, the List<Report> object has a count of 2 -- the "First Report" Report object is in there twice. Why? Here's the C#: public class Client { [System.Xml.Serialization.XmlArray("Reports"), System.Xml.Serialization.XmlArrayItem(typeof(Report))] public List<Report> Reports; } public class Report { [System.Xml.Serialization.XmlAttribute("Name")] public string Name; public bool Generate; [System.Xml.Serialization.XmlAttribute("Path")] public string Path; } class Program { static void Main(string[] args) { List<Client> _clients = new List<Client>(); string xmlFile = "myxmlfile.xml"; System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(List<Client>), new System.Xml.Serialization.XmlRootAttribute("Clients")); using (FileStream stream = new FileStream(xmlFile, FileMode.Open)) { _clients = xmlSerializer.Deserialize(stream) as List<Client>; } foreach(Client _client in _clients) { Console.WriteLine("Count: " + _client.Reports.Count); // This write "2" foreach(Report _report in _client.Reports) { Console.WriteLine("Name: " + _report.Name); // Writes "First Report" twice } } } }

    Read the article

  • Good conventions for embedding schema of a flat file

    - by Ville Koskinen
    We receive lots of data as flat files: delimitted or just fixed length records. It's sometimes hard to find out what the files actually contain. Are there any well established practices for embedding the schema of the file to the beginning or the end of a file to make the file self-explanatory? Just to get an idea, imagine something like this: <data name=test records=2 type=fixed> <field name=foo start=0 length=2 type=numeric> <field name=bar start=2 length=4 type=text> </data> 11test 12ing We would parse the xml in the beginning and use it for reading the records.

    Read the article

  • xs:choice unbounded list

    - by Matt
    I want to define an XSD schema for an XML document, example below: <?xml version="1.0" encoding="utf-8"?> <view xmlns="http://localhost/model_data" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost/model_data XMLSchemaView.xsd" path="wibble" id="wibble"> <text name="PageTitle">Homepage</text> <text name="Keywords">home foo bar</text> <image name="MainImage"> <description>lolem ipsum</description> <title>i haz it</title> <url>/images/main-image.jpg</url> <type>image/jpeg</type> <alt>alt text for image</alt> <width>400</width> <height>300</height> </image> <link name="TermsAndConditionsLink"> <url>/tnc.html</url> <title>Terms and Conditions</title> <target>_blank</target> </link> </view> There's a view root element and then an unknown number of field elements (of various types). I'm using the following XSD schema: <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/model_data" targetNamespace="http://localhost/model_data" id="XMLSchema1"> <xs:element name="text" type="text_field"/> <xs:element name="view" type="model_data"/> <xs:complexType name="model_data"> <xs:choice maxOccurs="unbounded"> <xs:element name="text" type="text_field"/> <xs:element name="image" type="image_field"/> <xs:element name="link" type="link_field"/> </xs:choice> <xs:attribute name="path" type="xs:string"/> <xs:attribute name="id" type="xs:string"/> </xs:complexType> <xs:complexType name="image_field"> <xs:all> <xs:element name="description" type="xs:string"/> <xs:element name="title" type="xs:string"/> <xs:element name="type" type="xs:string"/> <xs:element name="url" type="xs:string"/> <xs:element name="alt" type="xs:string"/> <xs:element name="height" type="xs:int"/> <xs:element name="width" type="xs:int"/> </xs:all> <xs:attribute name="name" type="xs:string"/> </xs:complexType> <xs:complexType name="text_field"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="name" type="xs:string"/> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:complexType name="link_field"> <xs:all> <xs:element name="target" type="xs:string"/> <xs:element name="title" type="xs:string"/> <xs:element name="url" type="xs:string"/> </xs:all> <xs:attribute name="name" type="xs:string"/> </xs:complexType> </xs:schema> This looks like it should work to me, but it doesn't and I always get the following error: Element <text> is not allowed under element <view>. Reason: The following elements are expected at this location (see below) <text> <image> <link> Error location: view / text Details cvc-model-group: Element <text> unexpected by type 'model_data' of element <view>. cvc-elt.5.2.1: The element <view> is not valid with respect to the actual type definition 'model_data'. I've never really used XSD schemas before, so I'd really appreciate it if someone could point out where I'm going wrong.

    Read the article

  • Read XML Files using LINQ to XML and Extension Methods

    - by psheriff
    In previous blog posts I have discussed how to use XML files to store data in your applications. I showed you how to read those XML files from your project and get XML from a WCF service. One of the problems with reading XML files is when elements or attributes are missing. If you try to read that missing data, then a null value is returned. This can cause a problem if you are trying to load that data into an object and a null is read. This blog post will show you how to create extension methods to detect null values and return valid values to load into your object. The XML Data An XML data file called Product.xml is located in the \Xml folder of the Silverlight sample project for this blog post. This XML file contains several rows of product data that will be used in each of the samples for this post. Each row has 4 attributes; namely ProductId, ProductName, IntroductionDate and Price. <Products>  <Product ProductId="1"           ProductName="Haystack Code Generator for .NET"           IntroductionDate="07/01/2010"  Price="799" />  <Product ProductId="2"           ProductName="ASP.Net Jumpstart Samples"           IntroductionDate="05/24/2005"  Price="0" />  ...  ...</Products> The Product Class Just as you create an Entity class to map each column in a table to a property in a class, you should do the same for an XML file too. In this case you will create a Product class with properties for each of the attributes in each element of product data. The following code listing shows the Product class. public class Product : CommonBase{  public const string XmlFile = @"Xml/Product.xml";   private string _ProductName;  private int _ProductId;  private DateTime _IntroductionDate;  private decimal _Price;   public string ProductName  {    get { return _ProductName; }    set {      if (_ProductName != value) {        _ProductName = value;        RaisePropertyChanged("ProductName");      }    }  }   public int ProductId  {    get { return _ProductId; }    set {      if (_ProductId != value) {        _ProductId = value;        RaisePropertyChanged("ProductId");      }    }  }   public DateTime IntroductionDate  {    get { return _IntroductionDate; }    set {      if (_IntroductionDate != value) {        _IntroductionDate = value;        RaisePropertyChanged("IntroductionDate");      }    }  }   public decimal Price  {    get { return _Price; }    set {      if (_Price != value) {        _Price = value;        RaisePropertyChanged("Price");      }    }  }} NOTE: The CommonBase class that the Product class inherits from simply implements the INotifyPropertyChanged event in order to inform your XAML UI of any property changes. You can see this class in the sample you download for this blog post. Reading Data When using LINQ to XML you call the Load method of the XElement class to load the XML file. Once the XML file has been loaded, you write a LINQ query to iterate over the “Product” Descendants in the XML file. The “select” portion of the LINQ query creates a new Product object for each row in the XML file. You retrieve each attribute by passing each attribute name to the Attribute() method and retrieving the data from the “Value” property. The Value property will return a null if there is no data, or will return the string value of the attribute. The Convert class is used to convert the value retrieved into the appropriate data type required by the Product class. private void LoadProducts(){  XElement xElem = null;   try  {    xElem = XElement.Load(Product.XmlFile);     // The following will NOT work if you have missing attributes    var products =         from elem in xElem.Descendants("Product")        orderby elem.Attribute("ProductName").Value        select new Product        {          ProductId = Convert.ToInt32(            elem.Attribute("ProductId").Value),          ProductName = Convert.ToString(            elem.Attribute("ProductName").Value),          IntroductionDate = Convert.ToDateTime(            elem.Attribute("IntroductionDate").Value),          Price = Convert.ToDecimal(elem.Attribute("Price").Value)        };     lstData.DataContext = products;  }  catch (Exception ex)  {    MessageBox.Show(ex.Message);  }} This is where the problem comes in. If you have any missing attributes in any of the rows in the XML file, or if the data in the ProductId or IntroductionDate is not of the appropriate type, then this code will fail! The reason? There is no built-in check to ensure that the correct type of data is contained in the XML file. This is where extension methods can come in real handy. Using Extension Methods Instead of using the Convert class to perform type conversions as you just saw, create a set of extension methods attached to the XAttribute class. These extension methods will perform null-checking and ensure that a valid value is passed back instead of an exception being thrown if there is invalid data in your XML file. private void LoadProducts(){  var xElem = XElement.Load(Product.XmlFile);   var products =       from elem in xElem.Descendants("Product")      orderby elem.Attribute("ProductName").Value      select new Product      {        ProductId = elem.Attribute("ProductId").GetAsInteger(),        ProductName = elem.Attribute("ProductName").GetAsString(),        IntroductionDate =            elem.Attribute("IntroductionDate").GetAsDateTime(),        Price = elem.Attribute("Price").GetAsDecimal()      };   lstData.DataContext = products;} Writing Extension Methods To create an extension method you will create a class with any name you like. In the code listing below is a class named XmlExtensionMethods. This listing just shows a couple of the available methods such as GetAsString and GetAsInteger. These methods are just like any other method you would write except when you pass in the parameter you prefix the type with the keyword “this”. This lets the compiler know that it should add this method to the class specified in the parameter. public static class XmlExtensionMethods{  public static string GetAsString(this XAttribute attr)  {    string ret = string.Empty;     if (attr != null && !string.IsNullOrEmpty(attr.Value))    {      ret = attr.Value;    }     return ret;  }   public static int GetAsInteger(this XAttribute attr)  {    int ret = 0;    int value = 0;     if (attr != null && !string.IsNullOrEmpty(attr.Value))    {      if(int.TryParse(attr.Value, out value))        ret = value;    }     return ret;  }   ...  ...} Each of the methods in the XmlExtensionMethods class should inspect the XAttribute to ensure it is not null and that the value in the attribute is not null. If the value is null, then a default value will be returned such as an empty string or a 0 for a numeric value. Summary Extension methods are a great way to simplify your code and provide protection to ensure problems do not occur when reading data. You will probably want to create more extension methods to handle XElement objects as well for when you use element-based XML. Feel free to extend these extension methods to accept a parameter which would be the default value if a null value is detected, or any other parameters you wish. NOTE: You can download the complete sample code at my website. http://www.pdsa.com/downloads. Choose “Tips & Tricks”, then "Read XML Files using LINQ to XML and Extension Methods" from the drop-down. Good Luck with your Coding,Paul D. Sheriff  

    Read the article

  • JBoss AS: use .xml files in the properties-service.xml

    - by fgysin
    The properties service (configured in properties-service.xml) in JBoss application server lets you specify external .properties files that are loaded and can then be accessed as system properties from the deployed applications. (See here http://community.jboss.org/wiki/PropertiesService for more info...) Is it also possible to load config files in the .xml format instead of .properties? I know it is possible for certain given configs like for example the mail-service.xml and the jboss-log4j.xml... But they are both loaded directly by JBoss, and not via the properties service.

    Read the article

  • JBOSS Security: web.xml vs. jboss-web.xml

    - by sixtyfootersdude
    What is the relation between web.xml and jboss-web.xml? Seems like: Jboss-web.xml specifies the security domain (which can be found in login-config.xml) web.xml specifies what the security level is I don't understand what happens when jboss-web.xml specifies a weak security domain. Ie: one that cannot do what web.xml specifies. What happens then?

    Read the article

  • How to write an RDF Schema?

    - by trickdev
    I am trying to get my head around using RDF to describe custom resources. I understand there are xmlns' out there such as Dublin Core and foaf which provide predefined element sets. How do I go about creating my own? I may be barking up the wrong tree of course and should stick to xml + xsd?

    Read the article

  • Is it possible to alternate between two types in an XML Schema

    - by lief79
    I'm wondering if I am missing something obvious. I have a list of numbers, possibly including ranges (think of the print page option of a print dialog). Ideally I'd like to have the final XML output look like this, with page and pageRange in an order. <pages> <page> 1</page> <pageRange><start>3</start><end>6</end></pageRange> <page> 34</page> </pages> What would I have to put into a schema to allow this? From what I saw: Sequence with multiple page and page Range allowed doesn't permit alternation. Choice only allows one or the other. I tried messing with all, but I wasn't getting it to validate properly. My short term solution is to have a sequence of ranges, and to force single numbers into the range, but it seems potentially cumbersome. So am I missing something?

    Read the article

  • xml schema putting both sequence and all under one complexType node

    - by exiang
    Here is the xml file: <section> <number>1</number> <title>A Title goes here...</title> <code>TheCode</code> <element></element> <element></element> </section> In section node, there are number, title and code node. Their sequence must not be fixed. Then, there are multiple element under section node as well. The idea is to use the following schema: <xs:complexType name="Type-section"> <xs:all> <xs:element name="number" minOccurs="0"></xs:element> <xs:element name="code" minOccurs="1"></xs:element> <xs:element name="title" minOccurs="1"></xs:element> </xs:all> <xs:sequence> <xs:element maxOccurs="unbounded" name="element"></xs:element> </xs:sequence> </xs:complexType> But it is invalid. I just cant put "sequence" and "all" together in the same level. How can i fix it?

    Read the article

  • Practical mysql schema advice for eCommerce store - Products & Attributes

    - by Gravy
    I am currently planning my first eCommerce application (mySQL & Laravel Framework). I have various products, which all have different attributes. Describing products very simply, Some will have a manufacturer, some will not, some will have a diameter, others will have a width, height, depth and others will have a volume. Option 1: Create a master products table, and separate tables for specific product types (polymorphic relations). That way, I will not have any unnecessary null fields in the products table. Option 2: Create a products table, with all possible fields despite the fact that there will be a lot of null rows Option 3: Normalise so that each attribute type has it's own table. Option 4: Create an attributes table, as well as an attribute_values table with the value being varchar regardless of the actual data-type. The products table would have a many:many relationship with the attributes table. Option 5: Common attributes to all or most products put in the products table, and specific attributes to a particular category of product attached to the categories table. My thoughts are that I would like to be able to allow easy product filtering by these attributes and sorting. I would also want the frontend to be fast, less concern over the performance of the inserting and updating of product records. Im a bit overwhelmed with the vast implementation options, and cannot find a suitable answer in terms of the best method of approach. Could somebody point me in the right direction? In an ideal world, I would like to offer the following kind of functionality - http://www.glassesdirect.co.uk/products/ to my eCommerce store. As can be seen, in the sidebar, you can select an attribute the glasses to filter them. e.g. male / female or plastic / metal / titanium etc... Alternatively, should I just dump the mySql relational database idea and learn mongodb?

    Read the article

  • Using XML as data storage

    - by Kian Mayne
    I was thinking about the XML format and the following quote: “XML is not a database. It was never meant to be a database. It is never going to be a database. Relational databases are proven technology with more than 20 years of implementation experience. They are solid, stable, useful products. They are not going away. XML is a very useful technology for moving data between different databases or between databases and other programs. However, it is not itself a database. Don't use it like one.“ -Effective XML: 50 Specific Ways to Improve Your XML by Elliotte Rusty Harold (page 230, Part 4, Item 41, 2nd paragraph) This seems to really stress that XML should not be used for data storage and should only be used for program to program interoperability. Personally, I disagree and .NET's app.config file that's used to store a program's settings is an example of data storage in an XML file. However for databases rather than configurations etc XML should not be used. To develop my point, I will use two examples: A) Data about customers with fields that are all on one level i.e. there are a number of fields all relating to one customer with no children B) Data about configuration of an application where nested fields and properties make a lot of sense So my question is, Is this still a valid statement and is it now acceptable to store data using XML? EDIT: I've sent an email to the author of that quote to ask for his input/extra context.

    Read the article

  • XML + Xslt -> Xml with PHP

    - by rokdd
    Hi, I know that there are really a mass of XML XSLT php merging threads at SO. But php specific i could not found what might my problem: $xml = new DOMDocument; $xml-load("f.xml"); $xsl = new DOMDocument; $xsl-load('test.xsl'); // init and configure processor $proc = new XSLTProcessor; $proc-importStyleSheet($xsl); // import xsl document $xml2=$proc-transformToXML($xml); echo $xml2; My xslt file looks a bit empty.. However i tried ´output method="xml"´. but it doesnot help.. PHP returns always the data as text or html but not in XML.. what i am doing wrong. I only want to edit the XML with xslt and save back to XML (file). THanks for your help!

    Read the article

  • Is there an application that can help someone create an XML document based on the Relax NG schema?

    - by meowsqueak
    I've spent a bit of time creating a Relax NG schema for use within our team to validate XML documents we use for exchanging information. The schema is not complicated, but it is reasonably large. I am wondering if there exists a tool that can read in such a Relax NG schema and assist a user in creating a corresponding instance document, using the schema as a template. Perhaps an application with a GUI that creates fields and drop-down selections for each part of the document? For example, the tool might create an outline XML document and prompt the user to select multiples of certain elements, fill in each field, perhaps with permitted values read directly from the schema. It might also show the user via visual feedback when their document is 'complete', or highlight validation problems as they come up. I could anticipate writing a custom GUI tool to create such an XML document, but I'd really like changes to the schema to be automatically reflected by the GUI - and I really wonder if this hasn't already been done. I know some editors can automatically validate an XML document against a schema as it's being written, but I would really like to get my users one step away from the XML so they don't have to worry about the details of the XML syntax.

    Read the article

  • Perl XML SAX parser emulating XML::Simple record for record

    - by DVK
    Short Q summary: I am looking a fast XML parser (most likely a wrapper around some standard SAX parser) which will produce per-record data structure 100% identical to those produced by XML::Simple. Details: We have a large code infrastructure which depends on processing records one-by-one and expects the record to be a data structure in a format produced by XML::Simple since it always used XML::Simple since early Jurassic era. An example simple XML is: <root> <rec><f1>v1</f1><f2>v2</f2></rec> <rec><f1>v1b</f1><f2>v2b</f2></rec> <rec><f1>v1c</f1><f2>v2c</f2></rec> </root> And example rough code is: sub process_record { my ($obj, $record_hash) = @_; # do_stuff } my $records = XML::Simple->XMLin(@args)->{root}; foreach my $record (@$records) { $obj->process_record($record) }; As everyone knows XML::Simple is, well, simple. And more importantly, it is very slow and a memory hog - due to being a DOM parser and needing to build/store 100% of data in memory. So, it's not the best tool for parsing an XML file consisting of large amount of small records record-by-record. However, re-writing the entire code (which consist of large amount of "process_record"-like methods) to work with standard SAX parser seems like an big task not worth the resources, even at the cost of living with XML::Simple. What I'm looking for is an existing module which will probably be based on a SAX parser (or anything fast with small memory footprint) which can be used to produce $record hashrefs one by one based on the XML pictured above that can be passed to $obj->process_record($record) and be 100% identical to what XML::Simple's hashrefs would have been. I don't care much what the interface of the new module is - e.g whether I need to call next_record() or give it a callback coderef accepting a record.

    Read the article

  • Declraing namespace schema with prefix in XSD/XML

    - by user1493537
    I am new to XML and I have a couple of questions about prefix. I need to "add the root schema element and insert the declaration for the XML schema namespace using the xc prefix. Set the default namespace and target of the schema to the URI test.com/test1" I am doing: <xc:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://test.com/test1" targetNamespace="http://test.com/test1"> </xc:schema> Is this correct? The next one is: "insert the root schema element, declaring the XML schema namespace with the xc prefix. Declare the library namespace using the lib prefix and the contributors namespace using the cont prefix. Set the default namespace and the schema target to URI test.com/test2" The library URI is http://test.com/library and contributor URI is test.com/contributor I am doing: <xc:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:lib="http://test.com/library" xmlns:clist="http://test.com/contributor" targetNamespace="http://test.com/test2"> </xc:schema> Does this look right? I am confused with prefix and all. Thanks for the help.

    Read the article

  • Perl XML SAX parser emulating XML::Simple record for record

    - by DVK
    Short Q summary: I am looking a fast XML parser (most likely a wrapper around some standard SAX parser) which will produce per-record data structure 100% identical to those produced by XML::Simple. Details: We have a large code infrastructure which depends on processing records one-by-one and expects the record to be a data structure in a format produced by XML::Simple since it always used XML::Simple since early Jurassic era. An example simple XML is: <root> <rec><f1>v1</f1><f2>v2</f2></rec> <rec><f1>v1b</f1><f2>v2b</f2></rec> <rec><f1>v1c</f1><f2>v2c</f2></rec> </root> And example rough code is: sub process_record { my ($obj, $record_hash) = @_; # do_stuff } my $records = XML::Simple->XMLin(@args)->{root}; foreach my $record (@$records) { $obj->process_record($record) }; As everyone knows XML::Simple is, well, simple. And more importantly, it is very slow and a memory hog - due to being a DOM parser and needing to build/store 100% of data in memory. So, it's not the best tool for parsing an XML file consisting of large amount of small records record-by-record. However, re-writing the entire code (which consist of large amount of "process_record"-like methods) to work with standard SAX parser seems like an big task not worth the resources, even at the cost of living with XML::Simple. What I'm looking for is an existing module which will probably be based on a SAX parser (or anything fast with small memory footprint) which can be used to produce $record hashrefs one by one based on the XML pictured above that can be passed to $obj->process_record($record) and be 100% identical to what XML::Simple's hashrefs would have been.

    Read the article

  • XML to be validated against multiple xsd schemas

    - by Michael Rusch
    I'm writing the xsd and the code to validate, so I have great control here. I would like to have an upload facility that adds stuff to my application based on an xml file. One part of the xml file should be validated against different schemas based on one of the values in the other part of it. Here's an example to illustrate: <foo> <name>Harold</name> <bar>Alpha</bar> <baz>Mercury</baz> <!-- ... more general info that applies to all foos ... --> <bar-config> <!-- the content here is specific to the bar named "Alpha" --> </bar-config> <baz-config> <!-- the content here is specific to the baz named "Mercury" --> </baz> </foo> In this case, there is some controlled vocabulary for the content of <bar>, and I can handle that part just fine. Then, based on the bar value, the appropriate xml schema should be used to validate the content of bar-config. Similarly for baz and baz-config. The code doing the parsing/validation is written in Java. Not sure how language-dependent the solution will be. Ideally, the solution would permit the xml author to declare the appropriate schema locations and what-not so that s/he could get the xml validated on the fly in a sufficiently smart editor. Also, the possible values for <bar> and <baz> are orthogonal, so I don't want to do this by extension for every possible bar/baz combo. What I mean is, if there are 24 possible bar values/schemas and 8 possible baz values/schemas, I want to be able to write 1 + 24 + 8 = 33 total schemas, instead of 1 * 24 * 8 = 192 total schemas. Also, I'd prefer to NOT break out the bar-config and baz-config into separate xml files if possible. I realize that might make all the problems much easier, as each xml file would have a single schema, but I'm trying to see if there is a good single-xml-file solution.

    Read the article

  • XSD: xs:sequence & xs:choice combination for xs:extension elements?

    - by bguiz
    Hi, My question is about defining an XML schema that will validate the following sample XML: <rules> <other>...</other> <bool>...</bool> <other>...</other> <string>...</string> <other>...</other> </rules> The order of the child nodes does not matter. The cardinality of the child nodes is 0..unbounded. All the child elements of the rules node have a common base type, rule, like so: <xs:complexType name="booleanRule"> <xs:complexContent> <xs:extension base="rule"> ... </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="stringFilterRule"> <xs:complexContent> <xs:extension base="filterRule"> ... </xs:extension> </xs:complexContent> </xs:complexType> My current attempt at defining the schema for the rules node is below. However, Can I nest xs:choice within xs:sequence? If, where do I specify the maxOccurs="unbounded" attribute? Is there a better way to do this, such as an xs:sequence which specifies only the base type of its child elements? <xs:element name="rules"> <xs:complexType> <xs:sequence> <xs:choice> <xs:element name="bool" type="booleanRule" /> <xs:element name="string" type="stringRule" /> <xs:element name="other" type="someOtherRule" /> </xs:choice> </xs:sequence> </xs:complexType> </xs:element>

    Read the article

  • Loading class instance from XML with Texture2D

    - by Thegluestickman
    I'm having trouble with XML and XNA. I want to be able to load weapon settings through XML to make my weapons easier to make and to have less code in the actual project file. So I started out making a basic XML document, something to just assign variables with. But no matter what I changed it gave me a new error every time. The code below gives me a "XML element 'Tag' not found", I added and it started to say the variables weren't found. What I wanted to do in the XML file as well, was load a texture for the file too. So I created a static class to hold my texture values, then in the Texture tag of my XML document I would set it to that instance too. I think that's were the problems are occuring because that's where the "XML element 'Tag' not found" error is pointing me too. My XML document: <XnaContent> <Asset Type="ConversationEngine.Weapon"> <weaponStrength>0</weaponStrength> <damageModifiers>0</damageModifiers> <speed>0</speed> <magicDefense>0</magicDefense> <description>0</description> <identifier>0</identifier> <weaponTexture>LoadWeaponTextures.ironSword</weaponTexture> </Asset> </XnaContent> My Class to load the weapon XML: public class Weapon { public int weaponStrength; public int damageModifiers; public int speed; public int magicDefense; public string description; public string identifier; public Texture2D weaponTexture; } public static class LoadWeaponXML { static Weapon Weapons; public static Weapon WeaponLoad(ContentManager content, int id) { Weapons = content.Load<Weapon>(@"Weapons/" + id); return Weapons; } } public static class LoadWeaponTextures { public static Texture2D ironSword; public static void TextureLoad(ContentManager content) { ironSword = content.Load<Texture2D>("Sword"); } } I'm not entirely sure if you can load textures through XML, but any help would be greatly appreciated.

    Read the article

  • Getting ActiveRecord (Rails) to_xml to use xsi:nil and xsi:type instead of nil and type

    - by nbeyer
    The default behavior of XML serialization (to_xml) for ActiveRecord objects will emit 'type' and 'nil' attributes that are similar to XML Schema Instance attributes, but aren't set in a XML Namespace. For example, a model might produce an output like this: <user> <username nil="true" /> <first-name type="string">Name</first-name> </user> Is there anyway to get to_xml to utilize the XML Schema Instance namespace and prefix the attributes and the values? Using the above example, I'd like to produce the following: <user xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xs="http://www.w3.org/1999/XMLSchema"> <username xsi:nil="true" /> <first-name xsi:type="xs:string">Name</first-name> </user>

    Read the article

  • XML Attributes or Element Nodes?

    - by Camsoft
    Example XML using element nodes: <?xml version="1.0" encoding="utf-8"?> <users> <user> <name>David Smith</name> <phone>0441 234443</phone> <email>[email protected]</email> <addresses> <address> <street>1 Some Street</street> <town>Toy Town</town> <country>UK</country> </address> <address> <street>5 New Street</street> <town>Lego City</town> <country>US</country> </address> </addresses> </user> </users> Example XML using attributes: <?xml version="1.0" encoding="utf-8"?> <users> <user name="David Smith" phone="0441 234443" email="[email protected]"> <addresses> <address street="1 Some Street" town="Toy Town" country="UK" /> <address street="5 New Street" town="Lego City" country="US" /> </addresses> </user> </users> I'm needing to build an XML file based on data from a relation database and can't work out whether I should use attributes or elements. What is best practice when building XML files?

    Read the article

  • .Net Xml Serialize - XSD Definition for Multiple Namespaces

    - by MattH
    The following XML was generated by serializing .Net objects: <?xml version="1.0" encoding="utf-8"?> <Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://EPS.WebServices/WebServiceSchema" > <Method xmlns="http://EPS.Library/RequestSchema">PackPlacementUpdate</Method> <Type xmlns="http://EPS.Library/RequestSchema">PackPlacementUpdate</Type> </Request> I am using XSD to generate a schema. However, (I think) because there are multiple namespaces two different schema files get generated. We will be providing the XSD file externally and I'm concerned that two files will cause confusion. Without changing the namespace of the .Net classes, is there is a way I can create a single XSD schema file and not two? Thanks.

    Read the article

  • php parsing xml result from ipb ssi tool

    - by Sir Troll
    Last week my code was running fine and now (without changing anything) it is no longer able to parse the elements out of the XML. The response from the ssi tool: <?xml version="1.0" encoding="ISO-8859-1"?> <ipbsource><topic id="32"> <title>Test topic</title> <lastposter id="1">Drake</lastposter> <starter id="18">Drake</starter> <forum id="3">Updates</forum> <date timestamp="1345600720">22 August 2012 - 03:58 AM</date> </topic> </ipbsource> enter code here Update: Switched to SimpleXML but I can't extract data from the xml: $xml = file_get_contents('http://site.com/forum/ssi.php?a=out&f=2&show=10&type=xml'); $xml = new SimpleXMLElement($xml); $item_array = array(); var_dump($xml); foreach($xml->topic as $el) { var_dump($el); echo 'Title: ' . $el->title; } The var_dump output: object(SimpleXMLElement)#1 (1) { [0]=> string(1) " " }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >