|
Because he's an a**hole who has posted everywhere, looking for some (probably) illegal code.
Bob
Ashfield Consultants Ltd
Proud to be a Code Project MVP
|
|
|
|
|
Maybe he is hoping for a prize.
I count 12 cross posts.
"GOLD award - for the most cross-posts on a single subject"
modified on Thursday, January 14, 2010 1:03 PM
|
|
|
|
|
Greeting!
As declared in w3.org there is predefined derived type in XSD schemas - the ENTITY. This type is used for attributes, which means are unparsed entities from DTD. Using of the ENTITY as attribute type in schema is not problem (no errors for the schema self-validation) but:
1. XML file didn't pass the schema validation - the XML file didn't find unparsed entities declared in the schema DTD (that's right - it is the schema DTD only) and from other hand the XML file DTD eliminates schema using (that's right too - the DTD is closed model). How to use the ENTITY type?
2. In XSD schemas there is predefined base type - NOTATION. The NOTATION takes values from the schema set of <notation> elements. In other words this replaces using of DTD NOTATION as attribute type. May be it is for the ENTITY type too?
|
|
|
|
|
You can't declare entities in XML Schemas. You can declare them in XML documents that are instances of the schema.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
No, IMHO it is impossible to declare entities in XML document if the document has schema because entities are declared in DTD and using of the DTD excludes using of the schema (DTD is closed model).
|
|
|
|
|
Sorry - it is possible - I've tried it successfully with Microsoft's XML parser.
See this page[^] of the XML schema recommendation which gives the example I used.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Sorry sir, can You show how You succeed? I can't validate this example. I have used Microsoft XML paser (DOM). There is error - Element "purchaseOrder" is used but not defined in DTD and schema. But there is the validation when I am commenting DTD in the XML file (and deleting symbol "&" for conversion entity to string literal). My JScript code fragment follows. Tell me please, where I have mistaken?
var xmldoc = WScript.CreateObject("MsXml2.DomDocument.5.0");
xmldoc.preserveWhiteSpace = false;
xmldoc.async = false;
xmldoc.validateOnParse = false;
xmldoc.load("a.xml");
printResult(xmldoc.parseError);
var schema = WScript.CreateObject("Msxml2.XMLSchemaCache.5.0");
schema.add("http://www.example.com/PO1", "a.xsd");
xmldoc.schemas = schema;
printResult(xmldoc.validate());
|
|
|
|
|
I used the .NET XML parser.
Here's my little C# program:
using System;
using System.Xml;
using System.Xml.Schema;
namespace a
{
class Program
{
static public void vvv(Object sender, ValidationEventArgs e)
{
Console.WriteLine(e.Message);
throw new XmlSchemaValidationException();
}
static void Main(string[] args)
{
try
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = false;
xmldoc.Load("Changes.xml");
Console.WriteLine(xmldoc.DocumentElement.Name);
Console.WriteLine("The document has {0} entities", xmldoc.DocumentType.Entities.Count);
XmlSchemaSet schema = new XmlSchemaSet();
schema.Add("", "change-history.xsd");
xmldoc.Schemas = schema;
xmldoc.Validate(vvv);
Console.WriteLine("Document validated!");
}
catch (XmlSchemaValidationException)
{
Console.WriteLine("Document didn't validate!");
}
}
}
}
Here's my schema (called change-history.xsd)
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:element name="change-history">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="items">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="item">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="version">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="change">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="reason" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="number" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="product" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
And here's my sample XML file
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE change-history [
<!ENTITY eacute "é">
]>
<change-history product="Sample" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="change-history.xsd">
<items>
<item name="Sample.exe">
<version number="2.21.0">
<change reason="issue 11">Added license to executable.</change>
<change>éFixed bug in executable.</change>
</version>
</item>
</items>
</change-history>
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Trez bien! Thank You very much! Your code is working without errors, validation is passed. But Your code converted to JScript is working with the same errors. Hence there are errors in the Ms COM implementation of Xml parser.
|
|
|
|
|
It does sound like the MS XML parser isn't complete to the standard You would have thought they'd have used the same one for both, wouldn't you
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi! Unfortunly, our long and winding road is continuing. The Ms .NET XML parser is not finished too. After passing Your successfull example, I tried to pass example of using unparsed entity. I added some entity and it notation in the DTD and some attribute definition of the ENTITY type in the schema. After I added this attribute with the unparsed entity value and executed Your program. The test was ok. But after I assigned to the attribute improper value (not unparsed entity) and test was once again ok! After my tests I have a mind that the parser checks attributes of the ENTITY type as of the the NCName type (the direct ancestor of the ENTITY type). The XML file and schema is here:
Changes.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE change-history [
<!ENTITY eacute "é">
<!NOTATION MyNotation SYSTEM "My Notation">
<!ENTITY MyEntity SYSTEM "My Entity" NDATA MyNotation>
]>
<change-history product="Sample" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="change-history.xsd">
<items>
<item name="Sample.exe">
<version number="2.21.0" entity = "MyEntity">
<change reason="issue 11">Added license to executable.</change>
<change>éFixed bug in executable.</change>
</version>
</item>
</items>
</change-history>
change-history.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:element name="change-history">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="items">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="item">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="version">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="change">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="reason" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="number" type="xs:string" use="required"/>
<xs:attribute name="entity" type="xs:ENTITY" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="product" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
From other hand, the DTD validation is strict - only unparsed entity can by the value of the ENTITY attribute. For the proving the XML file and C# program is here:
example.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE change-history [
<!ENTITY eacute "é">
<!NOTATION MyNotation SYSTEM "My Notation">
<!ENTITY MyEntity SYSTEM "My Entity" NDATA MyNotation>
<!ELEMENT change-history EMPTY>
<!ATTLIST change-history entity ENTITY #REQUIRED>
]>
<change-history entity = "MyEntity"/>
the program
using System;
using System.Xml;
using System.Xml.Schema;
namespace a
{
class Program
{
static void Main(string[] args)
{
try
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = false;
XmlValidatingReader reader =
new XmlValidatingReader(new XmlTextReader("Example.xml"));
reader.ValidationEventHandler +=
new ValidationEventHandler(vh);
reader.ValidationType = ValidationType.DTD;
xmldoc.Load(reader);
Console.WriteLine(xmldoc.DocumentElement.Name);
Console.WriteLine("The document has {0} entities", xmldoc.DocumentType.Entities.Count);
Console.WriteLine("Document validated!");
}
catch (XmlSchemaValidationException)
{
Console.WriteLine("Document didn't validate!");
}
}
static private void vh(Object sender, ValidationEventArgs args)
{
Console.WriteLine(args.Message);
throw args.Exception;
}
}
}
Of course, we can use double validation - at begining to use a schema validation and after success to use own validation routine checking the unparsed entities. But IMHO it's not fine decision.
|
|
|
|
|
I get an error
XQuery Execution Error! Unexpected token - "($email, '[A-Z0-9._%+-]+@"
in the following script
xquery version "1.0";
declare function local:valid-email($email as xs:string)
as xs:boolean
{
return matches($email, '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}')
};
Why does it occur?
Thanks --
Greetings - Jacek
|
|
|
|
|
Doesn't the 'matches' function need a namespace prefix?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
See my post below. That was a pure syntax error.
Greetings - Jacek
|
|
|
|
|
I have been programming in C too long. There is no "return" instruction in XQuery which means "return". It is a part of from(...) statement exclusively.
Solution:
xquery version "1.0";
declare function local:valid-email($email as xs:string)
as xs:boolean
{
matches($email, '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}')
};
Sorry for not posting the solution earlier.
Greetings - Jacek
|
|
|
|
|
When I try to open xml, that i created myself with IE, i get error: "There was a problem sending the command to the program". With this error showed IE also opens this xml. On the other side when i open it with Firefox, it opens xml without errors. What could be wrong with xml, that IE doesn't open it without errors?
|
|
|
|
|
|
how i can get value of tag
in xml file with C# codes.
example :
i wanna get value of Hello
|
|
|
|
|
class Program
{
class Sample
{
public Sample()
{
string xmlString = "<xml><item>a<!--Item A--></item><item>b<!--Item B--></item><item>b<!--Item C--></item></xml>";
XmlDocument document = new XmlDocument();
document.LoadXml(xmlString);
Console.WriteLine("Method 1");
XmlNodeList nodes = document.SelectNodes("xml/item");
foreach (XmlNode childnode in nodes)
{
if (childnode.LastChild.NodeType == XmlNodeType.Comment)
{
Console.WriteLine(childnode.LastChild.InnerText);
}
}
Console.WriteLine("\n\nMethod 2");
nodes = document.SelectNodes("xml/item/comment()");
foreach (XmlNode childnode in nodes)
{
Console.WriteLine(childnode.InnerText);
}
}
}
static void Main(string[] args)
{
Sample sample = new Sample();
Console.ReadLine();
}
}
Hope it helps!
|
|
|
|
|
I have a few nice xsd files which I want to convert to classes using xsd.exe. All the xsd's have the same includes, like this:
<xs:include schemalocation="FAP.xsd">
<xs:include schemalocation="IVR.xsd">
When I generate a class for each xsd the types declared in these files are duplicated for each original xsd.
Is there any way not to duplicate enums,clasess and etc.
Please assist me.
Regard,
Sri
|
|
|
|
|
Hi All,
I need to Generate controls like Label,Textbox dynamically using XSLT.As I am new to XSLT.I dont know how to get this,Can any one suggest me how can i do this and in how many ways we can get this.
I have to create a control including its properties dynamically like ID,name,textmode etc.. using XSLT code.
Thanks In Advance
|
|
|
|
|
Start here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi.
I have an xml document that im loading to the xmldocument class.
After loading i can see in the innerXML property the xml text.
Using the FirstChild propery gets me the "html" node.
But when im trying to get nodes , any nodes including the "html" node using the "selectNodes" or "selectSingleNode" using XPath, i always get zero nodes;
Example doc.SelectSingleNode("//html") . dosent return any node.
the xml code looks like that :
<br />
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="verify-v1" content="k1br6sikEUd0k3G96/qOGGoQOfCbjtZUn+oT10GDsHc=" /><meta name="keywords" content="lyric, lyrics, song, music, song lyrics, music lyrics" /><meta name="description" content="Lyrics.com is a music community with the largest searchable lyrics database." /><meta name="robots" content="all" /><meta name="server" content="10.1.10.2" /><title>Lyrics.com - your music community with the largest searchable lyrics database.</title><script type="text/javascript" src="http://www.lyrics.com/js/prototype.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/overlay.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/common.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/lyrics.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/users.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/scriptaculous.js"></script><link href="/stylesheets/main.v2.css" rel="stylesheet" type="text/css" /><!--[if IE 7]><link href="/stylesheets/ie7.css" type="text/css" rel="stylesheet" /><![endif]--><!--[if lt IE 7.]><script defer type="text/javascript" src="/js/pngfix.js"></script><![endif]--><!--[if IE 6]><link href="/stylesheets/ie6.css" type="text/css" rel="stylesheet" /><script src="/js/ie6.js" type="text/javascript"></script><script src="/js/pngfix.js" type="text/javascript"></script><![endif]--><!-- --><script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"></script><br />
<br />
.<br />
.<br />
.<br />
. <br />
<br />
</html><br />
Any ideas why?
Thanks
|
|
|
|
|
|
I have a DLL file I have been modifying but I'm stuck.
Inside the DLL are several duplicate xml files,images.............
What I am trying to do is change a reference in the xml file from calling 1 of the bitmaps
embedded in the dll to a folder location with the same named bitmap allowing for changing
the bitmap without editing the dll.
the xml code for referencing the bitmap looks like this
background = "resbmp(12260,7,-1,0,0,1,1)"
12260 being the bitmap name ,7,-1,0,0,1,1 being the dimensions, transparency...
how would I go about changing the resbmp reference to a folder location such as
c:user\Desktop\Images\12260.bmp
I am completely new to xml and I am stumped
|
|
|
|