How to tell the parser where to look for a local copy of xml.xsd? - xsd

I am creating an eclipse rcp application in which I am using SAXParser to parse an XML document. The "EventsDefinition.xsd" which I am using to validate the XML document has following import:
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml.xsd"/>
I keep the "EventsDefinition.xsd" & "xml.xsd" in the eclipse folder of the exported rcp product.
For accessing the "EventsDefinition.xsd", I use the following code which works.
URL fileURL = new URL(Platform.getInstallLocation().getURL() + "EventsDefinition.xsd");
File eventsDefinitionFile = new File(fileURL.getPath());
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", eventsDefinitionFile);
With this, the parser is able to access "EventsDefinition.xsd" but not the "xml.xsd" referenced by it, because it tries to find the xml.xsd relative to the directory from which the rcp application is executed.
Is there a similar way to tell the parser to find the "xml.xsd" at eclipse folder rather than in the present working directory?
I tried specifying schemaLocation="http://www.w3.org/2001/xml.xsd" in EventsDefinition.xsd, but it fails to read the schema. So I have to use the local copy of "xml.xsd" present at the exported product's eclipse folder.
Any suggestions will be extremely helpful.

I think that the problem is with the import declaration. First, although permitted, is not recommended to use "namespace" as a namespace prefix. Second, the problem arises form the fact that you use "http://www.w3.org/XML/1998/namespace" as namespace name, which is prohibited. Take a look here: http://www.w3.org/TR/REC-xml-names/#dt-prefix , precisely here:
The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to this namespace name, and it MUST NOT be declared as the default namespace.
Try to rename the namespace name to something else (and the namespace prefix too). Hope it helps.

Related

RazorEngine and Visual Studio 2015 IntelliSense

This post is not about ASP.NET MVC.
I am using RazorEngine for template processing available here:
https://antaris.github.io/RazorEngine/
The documentation states that I can have IntelliSense if I follow the instructions below:
https://antaris.github.io/RazorEngine/IntellisenseAndResharper.html
However, VS shows the following error:
The type or namespace name 'RazorEngine' could not be found (are you
missing a using directive or an assembly reference?)
Also the following errors:
The type or namespace name 'Linq' does not exist in the namespace
'System'
The type or namespace name 'Helpers' does not exist in the namespace
'System.Web'
The type or namespace name 'WebPages' does not exist in the namespace
'System.Web'
The type or namespace name 'WebPages' does not exist in the namespace
'System.Web'
The type or namespace name 'WebPages' does not exist in the namespace
'System.Web'
Am I getting the errors because I am editing the .cshtml in a command line project where the instruction assumes I use the web project? That doesn't make sense since RazorEngine does not have any project type requirement.
How can I address the issue? How can I edit .cshtml files in a command line project with IntelliSense without all of the above errors?
Found the answer
RTFM
According to the web page:
Your project output path is set to bin\ instead of bin\Debug\ and bin\Release.
another possible solution is to copy RazorEngine.dll and System.Web.Razor.dll to bin.
I am not deleting the post since it might help others.
Found the answer
RTFM
According to the web page:
Your project output path is set to bin\ instead of bin\Debug\ and bin\Release. another possible solution is to copy RazorEngine.dll and System.Web.Razor.dll to bin.

Finding the default project settings file

I'm trying to write a plugin for 3ds max, I went through the entire sdk installation process to the letter as described in the help files.
The problem I'm facing though is intellisence complaining about an invalid macro definition
"IntelliSense: command-line error: invalid macro definition:_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT =1"
I found the definition in project settigs -> c/c++ -> preprocessor definitions as inherited from parent or project default.
I tried disabling the inherited definitions and re-entered them, this time without the space between the name and the = and all works fine so I'm guessing its a typo on their part?
Anyway, I want to change the default project or whatever to not repeat it every time i start a new project. The project is created with a wizard which required me to copy over some files to appear and after which I had to enter the sdk path.
The files I copied are plain text with some fancy extensions and not much in them so I'm guessing the defaults are described in the sdk directory.. somewhere. Does anybody know what kind of a file I'm looking for?
EDIT: I found a file called root.vcxproj_template and it has a section for preprocessor definitions but all it contains is
<PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
and no mention of the broken one
EDIT2: in another part of the file there was a path to a property sheet (maxsdk\ProjectSettings\propertySheets\3dsmax.common.tools.settings) which included the faulty definition. I fixed it an no more complaints from VS.
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT = 1 means that compiler should replace all old C run-time routines such as sprintf, strcpy, strtok with new versions such as strprintf_s, strcpy_s, strtok_s and similar. It goes in pair with following definition _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES = 1.
More you can find here: (MSDN) https://msdn.microsoft.com/en-us/library/ms175759.aspx. However I tried to use this but without success. It says that you can use this only for statically allocated buffers like char buffer[32], but compilers was still complaining bout unsecure strcpy.

Inherit XSD namespace prefix

I have a lot XSD which access each other.
Since I'm changing to JAXB I'm currently looking for a straightforward way to add namespaces to the xsds according to their folder structure.
My main issue at the moment is to add the namespace to the XSD itself, to the import in the accessing file and also to the prefix definition in the accessing file.
Here a small example (not quite real live)
User.xsd - targetNamespace="common.user"
Message.xsd - targetNamespace="common.message"
Email.xsd - targetNamespace="email" xmlns:user="common.user" xmlns:message="common.message"
import namespace="common.user" schemaLocation="./common/user.xsd"
import namespace="common.message" schemaLocation="./common/message.xsd"
When I now have a new Message.xsd schema I have to duplicate 90% of my xsd header.
I was creating a Namespace.xsd xmlns:user="common.user" xmlns:message="common.message" which is then included by Email.xsd. But accessing e.g. user:name did not work.
Is there a way to save the namespace-prefix definition in a central XSD-file so I do not have to define them in every single xsd?
Also, is there a way to not need to set the namespace in the import when it is already defines in the imported xsd as targetNamespace?
I think (not 100% sure though) that including into the schema A a schema B which imports another schema C will give you access to C in A.
However you will still need to declare the namespace prefix (like xmlns:user="common.user").
ps. Just a warning - never ever do chameleon schemas. It does not seem that you plan to, but i still wanted to warn.

How to reference module files with Puppet?

I know that Puppet has first-class support for referencing module templates with the template function and now I find myself trying to find support for referencing module files. I was expecting that file('foomodule/barfile') or even file('foomodule/files/barfile') would correctly reference modules/foomodule/files/barfile, wherever the module may be located, but I seem to be forced into providing the fully qualified path to the file.
The reference documentation for the file function unfortunately doesn't provide any hints on how this can be accomplished, though I'm assuming there should be some elegant way to accomplish this.
Do you mean this ?
file { "some_file" :
source =>"puppet:///modules/foomodule/barfile",
owner => "root",
.....
}
puppet:///modules check the modulepath (/etc/puppet/module) in my case. The bar file will be located in
/etc/puppet/module/foomodule/files/barfile

How do I get the strong name of an assembly?

I need to 'friend' a dll library that I didn't author.
I can see in the properties that it has a strong name, but how can I find out what the strong name is, so I can use it in System.Runtime.CompilerServices.InternalsVisibleTo?
To get the public key of a strong-named assembly, use the sn tool:
sn -Tp assembly.dll
This will show you the public key that you need to put in the InternalsVisibleTo attribute. If you open a Visual Studio command prompt, the sn.exe tool will already be in the path.
However, I would question what you are trying to actually achieve. If you have a compiled assembly that you did not write, adding the InternalsVisibleTo attribute to your code will let it access the internals of your code, but it wouldn't have compiled without already having friend access. If you are trying to access the internals of the other assembly, then the InternalsVisibleTo attribute will need adding to the other assembly - something which you cannot do without recompiling it..
You have to specify fully qualified name and public key token in AssemblyInfo.cs file of assembly you "need a friend":
[assembly: InternalsVisibleTo("FullAssemblyName, PublicKey=....", )]
If you have Reflector.NET or ildasm in hand you can use it to see this information

Resources