All Questions
479 questions
1
vote
0
answers
45
views
How to sign XML document created using XmlSerializer and autogenerated classes from xsd.exe
I am having problems signing XML file created using auto-generated classes using xsd.exe on XML Schema.
My schema looks like this:
<?xml version="1.0" encoding="utf-8"?>
<...
0
votes
0
answers
46
views
Can an XSD have two elements with same name whose type is determined by an attribute value
I need to make an XSD schema (version 1.0) that is used for creating XML files by our clients, and for validation of the XML by us. Is it possible to make a XSD schema for the following XML file:
<?...
2
votes
3
answers
135
views
.NET 8.0 Not Normalizing Whitespace for xs:token Elements?
I'm working with C# and .NET 8.0.6.
I have an XSD that declares a "root" element with xs:token content. When I validate a document with an instance element that has padded content, the ...
0
votes
1
answer
490
views
How to fix the attribute is not declared while performing xml validation
How to resolve "The 'Level' attribute is not declared." error with next xml file:
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://...
0
votes
3
answers
179
views
XML Serialize difference between VS2022 & VS2019?
We use VS2019 for the project. We have some unit tests like this:
// Arrange
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-16\"?><LeadData xmlns:xsi=\&...
0
votes
0
answers
343
views
DDL Database generation from XSD
I have been provided with an XSD and an XML file. I need to save the information on the XML file onto an SQL database which does not exist yet.
I've tried using tools like Altova XMLspy and XSD2DB to ...
0
votes
1
answer
578
views
How to programmatically convert schema to C# class in .NET core
I'm looking for a way to convert schema to C# class in .NET core.
In .NET framework, i was using class XmlCodeExporter to achieve this but seems this has not been ported to .NET
For example, here is a ...
0
votes
1
answer
354
views
.NET 6 - reading Xml with schema as string
I'm trying to load an xml file which schema comes as a string:
using (MemoryStream memStream = GenerateStreamFromString(XsdSchemas.the_schema_string))
{
// tried this one too => using TextReader ...
0
votes
1
answer
171
views
What is a valid pattern for an XSD restriction consisting of an xs:float and an xs:string?
I try to validate by XSD an attribute that can contain a float type or a word "exist". After search in the net I found this solution, but it did not work when I tried this pattern:
<pre ...
0
votes
1
answer
304
views
How to tell xsd.exe to use a specific .NET type for a custom xs:simpleType?
In my XSD I have some type definitions like this:
<xs:simpleType name="Ref_System">
<xs:restriction base="xs:string">
<xs:pattern value="[a-fA-F0-9]{...
0
votes
1
answer
282
views
How to add element conditionally to XSD based on the value of another element
I have a scenario, where the first element (Mode) can have a value of either Add/Edit/Delete.
Now, I need to have another element (ID) based on the value of the first element.
if the first element ...
0
votes
0
answers
214
views
How to deserialize multiple xsd versions into one class?
My application reads in a certain type of XML files. I was provided with an XSD that I could deserialize using Visual Studio's xsd tool. Now, there are new versions of this XSD that should also be ...
0
votes
0
answers
292
views
Data at the root level is invalid. Line 1, position 1. Is it error with the xml format?
Im having a problem with reading my xml with an error of Data at the root level is invalid. Line 1,position 1.
This is my code below:
string soapmessage = response.Content;
XmlDocument ...
0
votes
0
answers
56
views
When does the XSLT document() function run schema validation on the external XML file?
Suppose I'm calling XslCompiledTransform.Transform on a reader created with ValidationType.Schema, XmlSchemaValidationFlags.ProcessSchemaLocation and with a resolver capable of finding the actual XSD ...
0
votes
0
answers
40
views
Where is a list of all possibilities of XmlSchemaExceptions throw in .NET?
I want to create a translation for the most common exceptions throwed by XmlSchemaExceptions using XmlReader in C# .NET. Didn't find anything on the web yet and don't want to manually generate ...
0
votes
1
answer
117
views
Change in XML serialization related to nillable attribute
I would like to know if anyone knows about some change in dot net libraries, that causes different way of serialization on nillable elements. Three months ago, our system was producing this kind of ...
0
votes
1
answer
101
views
Saxon EE .NET version evaluation, getting Method not found exception while validating the XSD
I am using Saxon 10.5 version .NET evaluation version. When trying to compile XSD its throwing below error.
Method not found: 'Void System.IO.FileStream..ctor(System.String, System.IO.FileMode, ...
0
votes
0
answers
45
views
Create one class used in all .cs files?
I have to create a Windows service in C# that will exchange 6 types of XML messages between Oracle database and IBM MQ queue.
I have created the XML classes using XSD schemas and xsd.exe. However, I ...
2
votes
3
answers
509
views
Multiple Versions C# classes/XSD using XSD.exe
I am using XSD.exe to convert a pretty complex XML-Schema (XSD-file) to C# Classes. I am then using XmlSerializer to read XML into memory and work with the data.
In the future, the XSD will change. So ...
0
votes
1
answer
61
views
Pass complex value to object for XML serialization
I have XSD file which was base to generate (by xsd.exe tool) C# classes for serialization. DotNetCore 3.1. Below is generated code
public partial class Deklaracje {
public PozycjeSzczegolowe ...
0
votes
1
answer
70
views
How to create an XML file via the following XSD
Based on the Schema i'm supposed to build an XML File looking exactly like the XML File i show below, i'm not able to change the structure or anything about it.
<?xml version="1.0" ...
0
votes
2
answers
133
views
Problems creating an xml file using an xsd file in c#
I need to create an XML file from an XSD file via a class. I'm new to programming so I followed this tutorial to make my first test XML and it worked out fine: Generating XML file using XSD file
But ...
0
votes
1
answer
81
views
How Do I Deserialize Into Local Collections in .NET?
I am trying to build a data pipeline in .NET. I have been given an xsd and have used the XML Schema Definition Tool to generate C# classes that represent the object model. In order to load this data ...
4
votes
0
answers
534
views
'xscgen' is not recognized as an internal or external command
I'm using the dotnet-xscgen to create .cs files from xsd files in my project.
My project file looks like the following
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
...
0
votes
1
answer
160
views
Force writing of default attribute values to xml file
I am working on a system that loads from and writes to XML files, it also parses these files in an a schema aware manor. However I need to interface with schema unaware applications. When I save my ...
1
vote
2
answers
85
views
XML date validation using XSD assertion with Saxon.Api (.NET version)
The validation rule: The EndDate should be greater than the StartDate when EndDate is not null/empty.
I'm getting an error on the last entry of employer while I'm expecting none. Am I doing something ...
4
votes
1
answer
5k
views
ArrayOfXElement to DataSet in C#
No, there is no appropriate answer in stack overflow yet. I am getting ArrayOfXElement in .net Core through Connected Services. But, I need to convert it into DataSet. How can I do that? I wrote the ...
0
votes
1
answer
36
views
Identify optional elements in XSD in c# once imported with CodeDom
I've analysed an XSD document inside which are some optional elements.
Within the produced C# code I find every int, decimal, datetime,... elements with an additional field xxxFieldSpecified. I ...
0
votes
2
answers
3k
views
Cannot switch to Unicode Error When Executing a Private Method
Hello I am receiving an error
(-<OrderUpdateReply>-<Error><ErrorDescription>There is no Unicode byte order mark. Cannot switch to Unicode.</ErrorDescription></Error>&...
0
votes
2
answers
130
views
Output xsd sequence information after simple element with dataset
I work with the xsd.exe to create a DataSet class for vb.net. All output data are contained inside this DataSet so I can use the DataSet.writexml(writer as XMLWriter) method to output the data to a ...
2
votes
1
answer
521
views
How to manage "NO-BREAK SPACE" used for formatting of XDocument?
Some users are trying to upload a document with U+00A0 NO-BREAK SPACE symbols used for formatting:
<myConfig>
<defaultConfig>
<defaultTitle>Hello!</defaultTitle>
</...
0
votes
0
answers
349
views
How does C# XML validation against XSD work? [duplicate]
I have created a library to validate the XML file with the XSD file using XmlReaderSettings. It works fine until the user fills data in the XSD file then changes XSD extension to XML and uses the ...
0
votes
1
answer
31
views
How to access XSDocument element?
I have the following XSD file and i cannot obtain the inner element with the name "document":
I have tried so far the following to no avail:
XDocument doc=Xdocument.Load([path]);
XNamespace ns="...
0
votes
0
answers
240
views
Unexpected node type Element when generating classes
I have an XSD and would like to serialise it into a C# class. My current process is
Go to https://www.liquid-technologies.com/online-xsd-to-xml-converter
to convert the XSD to XML and then convert ...
4
votes
1
answer
1k
views
XML validate using XSDs with imports and includes in .net core
I want to validate XML documents against xsds with includes and imports, without includes and imports this code work.
These are 4 xsds used to validate xml.
Main.xsd
<?xml version="1.0" encoding="...
-1
votes
1
answer
42
views
how do we deal with not knowing the prefix/namespace?
How do I iterate through a specific xpath against an XmlDocument that has no prefix/namespace ?
I'm parsing XML like so :
var doc = new XmlDocument();
doc.LoadXml(input);
var ...
0
votes
2
answers
1k
views
Extend existing XSD schema with custom attribute
I need to add some custom attribute to xml file that is validated by existing, already defined schema.
Given existing xml element:
<existingElement attr1="1" attr2="2" />
Validated with ...
1
vote
1
answer
837
views
Java Service - SOAP Responses return always NULL to .NET
I have an SOAP 1.1 Service developed with Spring Boot in Java which responses without any problems to any of my requests and deliver a valid SOAP-response.
Now the problem is as soon as I add this ...
0
votes
2
answers
72
views
how to iterate through intersection of nodes
How can I iterate only through the common nodes between two documents?
Right now, I am able to iterate through all the nodes of my document:
var xmlBody = @"<?xml version="1.0" encoding="UTF-8"?&...
1
vote
1
answer
213
views
Xml schema validation does not fail on trailing line-feed
Using the XmlReader, I'm performing schema validation on XML elements who's datatype does not allow line-feeds. If the value contains a line-feed at the beginning or anywhere before the end of the ...
1
vote
0
answers
70
views
.NET XMLSerializer ignores attributes on serialize [duplicate]
I have a class generated by the xsd.exe tool. It doesn't matter what class, the same problem occurs always which is that every attribute having a type other than string is being ignored when the ...
0
votes
1
answer
1k
views
Wildcard ##any error xml schema validation
Getting the error above while validating the XSD against the schema in C#. Schema looks for the listed tags and other tags coming in are optional.
Below is my XSD file. How the xml file will need to ...
0
votes
2
answers
1k
views
Validate XML without XSD
I have an XML file coming in and need that to have a few specific tags without that I cannot process that file. How can I make sure if those tags are there or not , I tried using the XSD validation ...
0
votes
1
answer
1k
views
What is the best tool for generating C# classes out of XSD? [closed]
Is there a modern and regularly updated tool for generating C# v.7+ classes of XSD? The only tool I know is xsd2code but it is not free and its last update, according to the official site was "Update ...
0
votes
0
answers
217
views
Getting The complexType 'MaximumPowerType' has already been declared from an AMAZON submit call
Amazon documentation is not clear so I am turning here for help. Five days ago our console program that feeds various data to Amazon from our system started to toss back this error.
...
0
votes
1
answer
153
views
Creating web service from WSDL involving complex type without XSD
I am creating a web service that reflects my WSDL. This WSDL contains complex type which I assume is because it has an XSD as well(which I don't have). The question is can I create a proxy class of ...
0
votes
0
answers
127
views
Unexpected output of xsd.exe
Consider the following simple schema:
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MyRoot">
&...
0
votes
1
answer
201
views
When validating xml against xsd in SaxonEE/dotNet; how do I invoke SetInvalidityHandler?
All I have is: "You can call SetInvalidityHandler(IInvalidityHandler inHandler). This will cause each validity error to be reported to your supplied handler. The error is reported by way of a (poorly ...
1
vote
1
answer
1k
views
Change autogenerated class' XmlSerialization's namespace handling
I'm currently in the process to create a bunch of files that should then be used by a different programm. Most of them are XML-Files. Naturally, I extracted the .xsd files from the program and used ...
3
votes
1
answer
1k
views
Howto create code from wsdl and separated Xsd
i got a local wsdl file referencing two separate Xsd files.
how can I create the relate [c#] classes to that service ?
I tried to use wsdl.exe , but it ignores the Xsd files located in the same ...