|
in order to know if they are different (without counting) you can compare the xml-strings:
in VB:
dim domFile1 as new DomDocument
dim domFile2 as new DomDocument
domFile1.load "C:\file1.xml"
domFile2.load "C:\file2.xml"
If domFile1.xml = domFile2.xml Then ....
what do you need?
Sebastian
|
|
|
|
|
There is a problem:
I have a HTML file with embedded XML document.
The document contains binary data within a tag.
...
...
<pictute>
FBYxVhUiQVGV0hcjMldhdZOl0dQ3gaSz0zNCRlNUdsI0NVVmkZS Q3GEobEINjhFSHKGgAIAQEAAD8A39ERERERERFx3a5Q2azV10qG
yOgoqeSokbGAXFrGlxAyQM4HrCoem9Wa9uFZZq+5aboXWC87jD1
GUunomEb43zFztpaWD+bjv7g7DHLvxHrNPXG7WC6U0B1DNKOz8F
..
..
..
This binary data is JPEG , that I want to display in web browser (namely IE)
the queston is :
How can I dispaly the image without saving it to disk file?
(Now I do it this way :
- save data to file on local disk drive
- set "src" attribute of an tag to the
location of the file
)
Thanx for any suggestions
Michal Januszczyk
|
|
|
|
|
You will have to write a program to decode the data, save it to a well-known location, and then set an img tag to point at it. That seems to be the only way...
|
|
|
|
|
.. I stumbled upon the following today I hope it helps.
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q254388
You shoudl be able to convert it to something useable.
Al.
Alice thought that running very fast for a long time would get you to somewhere else. " A very slow kind of country!" said the queen. "Now, here , you see, it takes all the running you can do, to keep in the same place".
|
|
|
|
|
When a space is given in .xml file, the value is not passed & it is not displayed in the browser.
|
|
|
|
|
Do you mean a whitespace character? If you want to show that, rather use  .
|
|
|
|
|
Can you provide an example. Where is the space character that it doesn't show up? Are you just opening the document, in say IE, or are you doing any processing of it?
|
|
|
|
|
Depending on which version of MSXML you have whitespace defaults are different.
In VC++ the following line will preserve the whitespaces if called prior to loading the file.
hr = pXML->put_preserveWhiteSpace(VARIANT_TRUE);
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
The FieldTypes type works fine in the Visual Studio.NET editor, but for some reason, I can't get the FileExtension type to work. Any ideas?
<xs:simpleType name="FieldTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="Number" />
<xs:enumeration value="String" />
<xs:enumeration value="SSN" />
<xs:enumeration value="Money" />
<xs:enumeration value="Date" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="FileExtension">
<xs:restriction base="xs:string">
<xs:pattern value="\d{2}"/>
</xs:restriction>
</xs:simpleType>
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
The following checks ok for me:
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" elementFormDefault = "qualified">
<xs:simpleType name="FieldTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="Number" />
<xs:enumeration value="String" />
<xs:enumeration value="SSN" />
<xs:enumeration value="Money" />
<xs:enumeration value="Date" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="FileExtension">
<xs:restriction base="xs:string">
<xs:pattern value="\d{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
How are you defining your namespace? and or can you describe what you mean by not getting it to work?
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
Sorry. I was in a hurry to post this yesterday, as I was on my way out the door. I'm trying to validate that a file extension was correct. The '\d{2}' was just a test; the string I had in there originally was '\.\W{1,4}', which, if I remember correctly, means "a dot, followed by 1 to 4 non-whitespace charectors". My namespace is declared as you have it. In the Visual Studio.NET editor, if I type anything other than an enumeration member for the 'Type' attribute (declared as FieldType), I get the red squiggly line underneath. But the same is not true for an invalid file extension. I don't know. Back to the drawing board, I guess.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
Jamie,
I really have not done much with patterns. But if I am reading the spec right, you need a small 'w' not a capital 'W'.
http://www.w3.org/TR/xmlschema-2/#rf-pattern
You have to have a slightly different setup for Visual Studio as mine lets me type anything in with no error checking.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
I hate "why doesn't this work" posts but I'm at wits end.
Here's a snippet of my xml schema (I took off the angle brackets so it would show up).
msgIDType and TextFieldType are defined later in the file.
?xml version="1.0"?
xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsd:element name="message"
xsd:complexType
xsd:sequence
xsd:element name="msgID" type="msgIDType"
xsd:element name="TextField" type="TextFieldType"
/xsd:sequence
/xsd:complexType
/xsd:element
Now I'm using a simple validation script that is based on MSXML4 it returns this error...
Error: End tag 'xsd:sequence' does not match the start tag 'xsd:element'
I've checked all sequences and elements and each one has a matching end tag. I've also made sure that one doesn't begin before the other ends. So what else am I missing?
nay
|
|
|
|
|
If all you removed was the angle brakets then your "middle" xsd:elements are not terminated.
nay wrote:
xsd:element name="msgID" type="msgIDType"
xsd:element name="TextField" type="TextFieldType"
should be:
xsd:element name="msgID" type="msgIDType"/
xsd:element name="TextField" type="TextFieldType"/
And would give you the mentioned error.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
Thanks for the reply! Unfortunately the code is at work so I cannot check it to see if that's what I did. I was sure I put the / on the end but who knows. It is the weekend so I'll worry about it on monday.
nay
|
|
|
|
|
Hello,
I am storing the database data in the XML file. Using the XSL file I want to retrieve the selected data from the XML file. I have tried using <xsl:choose>, <xsl:when>, <xsl:if>, but I am not getting the desired results. If I use <xsl:if>, the page is not rendered & the drop down control is displayed as a plain text. If I use <xsl:when>, the condition is not being tested.
Can anypne tell me exactly what could be the problem?
Thanks in advance
Hitesh
|
|
|
|
|
It would help a lot if you could provide an example of your XML and what you are trying to retrieve.
<tip>Write < when you want to show the < character.</tip>
|
|
|
|
|
Hi,
Thanks for the reply.
Following is the part of the code
<xsl:choose>
<xsl:when test=".[CardType=3]">
Credit Card Option1
<xsl:element name="select">
<xsl:attribute name="name">D2
<xsl:element name="option">
<xsl:attribute name="value"><xsl:value-of select="CardOptionParent1">
<xsl:when test=".[CardType='4']">
Credit Card Option1
<xsl:element name="select">
<xsl:attribute name="name">D2
<xsl:element name="option">
<xsl:attribute name="value"><xsl:value-of select="CardOptionParent2">
<xsl:otherwise>
Credit Card Option1
<xsl:element name="select">
<xsl:attribute name="name">D2
<xsl:for-each select="data/record/field1">
<xsl:element name="option">
<xsl:attribute name="value"><xsl:value-of select="CardLicenceOption">
<xsl:value-of select="CardLicenceOptionDescription">
CardType is the tag in my XML file. Based on the value of CardType selected, I want to display the values from the XML file.
Let me know if you can understand this. I wanted to attach my .xsl file but there is no way I can attach the file.
Thanks
Hitesh
|
|
|
|
|
I'm guessing your XML looks something like this:
<cards>
<card><CardType>1</CardType>
<data>
<record>
<field1>
<CardLicenceOption>1</CardLicenceOption>
<CardLicenceOptionDescription>Credit</CardLicenceOptionDescription>
</field1>
<field1>
<CardLicenceOption>2</CardLicenceOption>
<CardLicenceOptionDescription>Charge</CardLicenceOptionDescription>
</field1>
</record>
</data>
</card>
<card><CardType>3</CardType>
<CardOptionParent1>1</CardOptionParent1>
<CardOptionDescription>Cash</CardOptionDescription>
</card>
</cards>
It looks like you're using incorrect paths to access your XML elements. The following XSLT should work:
<xsl:for-each select="//card">
<tr><td width="50%">Credit Card Option1
<xsl:choose>
<xsl:when test="CardType=3">
<xsl:element name="select">
<xsl:attribute name="name">D2</xsl:attribute>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="CardOptionParent1" />
</xsl:attribute>
<xsl:value-of select="CardOptionDescription" />
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:when test="CardType=4">
<xsl:element name="select">
<xsl:attribute name="name">D2</xsl:attribute>
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="CardOptionParent2" />
</xsl:attribute>
<xsl:value-of select="CardOptionDescription" />
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="select">
<xsl:attribute name="name">D2</xsl:attribute>
<xsl:for-each select="data/record/field1">
<xsl:element name="option">
<xsl:attribute name="value">
<xsl:value-of select="CardLicenceOption"/>
</xsl:attribute>
<xsl:value-of select="CardLicenceOptionDescription" />
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</td></tr>
</xsl:for-each>
|
|
|
|
|
I'm interested in implementing my applications log files as XML. From what little I know of XML, DOM requires that you load the entire document before you can manipulate nodes. Fine for reading, but if I'm logging a lot of items, I don't want to have to open the file, read the entire document, add a node, then close again.
Does anyone have any experience doing XML logging? Is it worth the trouble? Got any examples or advice on non-DOM implementations?
|
|
|
|
|
I would not use XML files for logging. They are text files as you state, open and closing all of the time. Some database would be better. You can then always export the database to an XML file when needed for processing or archiving.
XML and related technologies are great but they are not pixie dust for all of the worlds troubles.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
You could use one of two approaches if you do not plan to read the log file (only write to it):
- You could use the SAX interface to write entries to the log file
- You could write include XML tags in your log messages, making it possible to process the log later with an XML processor
The second option is, by far, the easiest to implement. I wrote an article for another Web site back in November 2001 that covers most of option #1 - here's the link (new window): Using the Microsoft XML Parser to Create XML Documents
Essam - Author, JScript .NET Programming
...and a bunch of articles around the Web
|
|
|
|
|
here's what I did, but we didn't run this production yet
1) construct one line of valid xml
2) write it to text file , flush buffer
This produced a text file that resembled xml, but missing the top-level node. To display it in a web page, I pre-pended a top-level node ( < TOP > ) , and appended a closing node name
( < / TOP > ), and this worked.
I think one possible advantage is that it is super fast and simple to write a line of text, and then you can take care of the leading and trailing niceties later when you display the file.
Also, this approach ignores the DOM entirely. It is only straight C text files at the time of logging.
|
|
|
|
|
We have done something similar, and for the first time files, if you check their existance before opening them, you can write out the xml header for a new file. You can also write out any trailer information, and if it is static, then when you open the file, you can re-position the file pointer (using fseek) to be that number of characters back from the end, write out your new data, and rewrite the static (ie, fixed/known length) trailer. It's a little clumsy, but it helps to know that you can re-position the file pointer.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
This has been driving me crazy! I am trying to use XSL to output a nice pretty XHTML page from my XML feed. And of course, all nice pretty XHTML pages include a !DOCTYPE declaration. But whenever I try and simply stick it in my <xsl:template> tag, it gives me this error:
<br />
<br />
Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'file:///C:/Inetpub/wwwroot/PageWriter/Template.xsl'. Line 13, Position 13<br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
------------^<br />
I've tried a variety of things, such as splitting up the !DOCTYPE into various pieces and putting them in <xsl:text> elements, but that didn't work.
Anybody know the answer? This must be a fairly common question, not all XHTML and HTML outputs can be sloppily tossed out w/o a !DOCTYPE (i.e. like they are in all examples I can find).
-Domenic Denicola- [CPUA 0x1337]
MadHamster Creations
"I was born human. But this was an accident of fate - a condition merely of time and place. I believe it's something we have the power to change..."
|
|
|
|