Giter VIP home page Giter VIP logo

Comments (8)

mamift avatar mamift commented on August 23, 2024

You have to use a configuration file with CLR namespaces mapped to XML namespaces. See this folder for an example (it already uses the same XSD you're using):

https://github.com/mamift/LinqToXsdCore/tree/master/LinqToXsd.Schemas/XSD

from linqtoxsdcore.

Joebeazelman avatar Joebeazelman commented on August 23, 2024

Thanks for getting back to me. I don't think this is the issue. I used the command line option to generate a sample configuration file and modified the CLR namespace mapping:

<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns="http://www.microsoft.com/xml/schema/linq">
  <CodeGeneration>
    <SplitCodeFiles By="Namespace" />
  </CodeGeneration>
  <Namespaces>
    <Namespace DefaultVisibility="public" Schema="http://www.w3.org/2001/XMLSchema" Clr="w3.Xsd.Schema" />
    <Namespace DefaultVisibility="public" Schema="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty" Clr="w3.Xsd.Schema.hasFacetAndProperty" />
  </Namespaces>
  <Validation>
    <VerifyRequired>false</VerifyRequired>
  </Validation>
  <Transformation>
    <Deanonymize strict="false" />
  </Transformation>
</Configuration>

The configuration file you linked to only maps a single namespace, but the configuration generator generated two namespaces. I removed the second namespace from the config and I still get the same error message.

The code generates two namespaces regardless of whether I map only one or both namespaces. There's a strange namespace www.w3.org.XML.Item1998.@namespace which is generated and I don't know where it picked it up from. Am I using the wrong XMLSchema.XSD?

namespace w3.Xsd.Schema {
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.IO;
    using System.Linq;
    using System.Diagnostics;
    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Linq;
    using Xml.Schema.Linq;
    using www.w3.org.XML.Item1998.@namespace;    <-- where did this come from?
  
    }

...
namespace www.w3.org.XML.Item1998.@namespace {.   <-- what's all this?
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.IO;
    using System.Linq;
    using System.Diagnostics;
    using System.Xml;
    using System.Xml.Schema;
    using System.Xml.Linq;
    using Xml.Schema.Linq;
    using w3.Xsd.Schema;
    
    
    public sealed class lang {
        
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        public static Xml.Schema.Linq.SimpleTypeValidator TypeDefinition = new Xml.Schema.Linq.UnionSimpleTypeValidator(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.AnyAtomicType), null, new Xml.Schema.Linq.SimpleTypeValidator[] {
                    new Xml.Schema.Linq.AtomicSimpleTypeValidator(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Language), null),
                    new Xml.Schema.Linq.AtomicSimpleTypeValidator(XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String), new Xml.Schema.Linq.RestrictionFacets(((Xml.Schema.Linq.RestrictionFlags)(16)), new object[] {
                                    ""}, 0, 0, null, null, 0, null, null, 0, null, 0, XmlSchemaWhiteSpace.Preserve))});
        
        private lang() {
        }
    }
}

from linqtoxsdcore.

mamift avatar mamift commented on August 23, 2024

OK took a second look and it appears to be a regression bug with the code generator; it's supposed to prepend the global keyword when referring to the TypeDefinition of the class.

The link I gave earlier does contain compilable code generated from an earlier version of LinqToXsdCore that did not exhibit the bug so in the meantime it might be worth just copying the code from the above folder instead of generating it yourself.

from linqtoxsdcore.

Joebeazelman avatar Joebeazelman commented on August 23, 2024

OK. No problem. I was one of the contributors to libXML way back in the 90s. For my project, I also investigated using XSLT and after 15 minutes I ran back screaming to .NET. I can't believe XSLT still doesn't have a built-in, comprehensive set of functions for text operations such as word wrap, space trimming, etc. The idea of using XML to write functions isn't appealing. While I Don't expect LinqToXsd to have a wide range of text operations, the .NET framework and or whatever templating language makes it a non-issue.

from linqtoxsdcore.

mamift avatar mamift commented on August 23, 2024

While I Don't expect LinqToXsd to have a wide range of text operations, the .NET framework and or whatever templating language makes it a non-issue.

May I ask what you're using LinqToXsd for? It's not meant as a replacement for XSLT, but I guess depending on how you use it, it can render XSLT redundant. The LINQ to XML API is probably better suited as a replacement for XSLT, especially if you don't actually have access to a schema for the XML you're trying to process. LINQ to XML is what LinqToXsd actually uses and depends on.

With respect to text operations, LinqToXsd doesn't really provide any additional text/string manipulation facilities beyond what's already in the .NET API (string, Regex etc).

Conceptually this library is a couple levels above XSLT, even a level above XQuery even, because of the types it generates.

from linqtoxsdcore.

Joebeazelman avatar Joebeazelman commented on August 23, 2024

You'll hate me for it, but I'm writing an XSD to Ada source code generator. I'm using C# and .NET as a springboard or booster to generate XSD data structures in Ada. They will be used in implementing the Ada code generator in Ada. At that point, I can jettison the .NET/C# booster since it's recreated it in Ada. It's kind of hard to wrap your head around as it is recursive at the architectural level.

The reason for this weird strategy is two-fold. First, the tooling and libraries available for Ada development is sad. It does have an XML parser, but for a language that advertises type safety, accessing elements by their string names, defeats the point. It's also painful to work with unless you write accessors for all the elements you're interested in. Hopefully, this project will assist it making XML more pleasant for others by simply generating the strongly-typed code for any XSD.

Second, along the development process, I can use the .NET booster code I've written as a reference for the Ada code. The languages are different, but the actual code generation is similar. I could just stop after completing the booster and release it as a .NET-based tool for Ada, but it's not a good advertisement for a language struggling in popularity, despite its impressive design and safety.

from linqtoxsdcore.

mamift avatar mamift commented on August 23, 2024

That sounds like a very interesting project. Very niche though (not saying that's a bad thing!)

And Ada is an intriguing language, but mapping XSD to Ada code should be easier than XSD to C#. It's interesting that parts of the XML Schema's type system already existed in Ada, like restricting a string type 'Weekday' to an enumeration of possible day names ('Mon', 'Tue', 'Wed'), or an int to a range of values. I wish you could do easily in C#!

from linqtoxsdcore.

Joebeazelman avatar Joebeazelman commented on August 23, 2024

Yes, the restrictions should make it easier to implement it in Ada, but Ada is very pedantic which is a good thing considering you can get your code to run on the first execution. Ada is far more popular in Europe than in the US.

from linqtoxsdcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.