|
you can use xmldocument to create the xml file.
All The Best
Sathesh Pandian
|
|
|
|
|
Hi,
Dim dom As New Xml.XmlDocument
dom.LoadXml("<root>")
Dim root As Xml.XmlElement = dom.DocumentElement
Dim Elem As Xml.XmlNode = dom.CreateNode(Xml.XmlNodeType.Element, "item", "")
Elem.InnerText = "XYZ"
root.AppendChild(Elem)
MsgBox(dom.DocumentElement.OuterXml)
dom.Save("dom.xml")
for more details go to http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]
hope this helps
|
|
|
|
|
I am trying to remove some unwanted elements from a source XML document using XSLT and JAXP and create a new XML document in which those unwanted elements are not present. My XSLT works fine and removes the desired elements when there is no XMLNS attribute defined in root node of XML document. But the same java code & XSLT doesn't removes those elements when XMLNS attribute is set in root node of source XML document.
In following example, I am trying to remove "outstation" elements from XML doc.
Sample XML:
<?xml version="1.0" encoding="UTF-8"?>
<Contacts version="110000000" xmlns="http://www.contacts.com/transform">
<Messenger>
<yahoo>
<id name="abc">abc21@yahoo.com</id>
<id name="xyz">xyz21@yahoo.co.in</id>
</yahoo>
<msn>
<id name="abc">abc21@hotmail.com</id>
<id name="xyz">xyz21@msn.com</id>
</msn>
</Messenger>
<Phone>
<local>
<no name="abc">12345678</no>
<no name="xyz">12345670</no>
</local>
<outstation>
<no name="abc" country="india">08012345678</no>
<no name="xyz" country="india">08012345670</no>
</outstation>
</Phone>
</Contacts>
Sample XSLT:
<?xml version = '1.0' encoding = 'UTF-8'?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding ='UTF-8' indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="outstation">
</xsl:template>
</xsl:transform>
Java code snippet:
public static void main(String[] args) throws Exception
{
....
....
Source xmlSource = new StreamSource(srcFile);
Source xsltSource = new StreamSource(xsltFile);
StreamResult result = new StreamResult(resFile);
TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, result);
...
...
}
Is there anyway to solve this problem, other than using DOM?
-- modified at 8:59 Wednesday 18th July, 2007
|
|
|
|
|
Well strangely I am reply to my posted query ..
In the given example, it is expected that template in the XSLT, <xsl:template match="outstation"> </xsl:template>, should remove all occurrence of "outstation" elements from the XML document.
This XSLT will work fine for any XML document which doesn't has a "DEFAULT NAMESPACE" declared in root element. In given example, I have declared a default namespace in root element as 'xmlns="http://www.contacts.com/transform"'. Because of the default namespace, the expanded name of element is pair of URI name and Element name (URI name here is "http://www.contacts.com/transform"). So the template defined in XSLT for "outstation" element will fail to match any <outstation> element in XML file.
As the namespaces link the XML & XSLT through a URI. So the solution to this problem is to add a namespace prefix with the namespace name "http://www.contacts.com/transform" in the xslt file and then use the prefix in the XPath statements as shown below:
Solution is in XSLT:
<?xml version = '1.0' encoding = 'UTF-8'?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:txf="http://www.contacts.com/transform">
...
...
...
<xsl:template match="txf:outstation">
</xsl:template>
</xsl:transform>
|
|
|
|
|
please tell me how to compile or convert html to XML. Please tell me How compilation differs from convert. Thanks
|
|
|
|
|
I don't understand exactly what you are talking about? Nevertheless, HTML and XML are related markup languages and are usually text files. XHTML is a strict form of HTML since it obeys an XML type-schema. Once you have your document in XHTML, you can transform it to another XML document using XSLT.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
Im quite new to xpath in .Net. I have an XML-structure shown below that contain measurements(diameters,areas etc) The one below includes two different measurements of an Bi diameter and also the mean value. I now want to extract the mean value.(the <value>5.0</value> tag.
As mentioned ,the file consists of many different measurements using the same strucutre. With the following expression I manage to extract the value but then I also get all the following mean values from all of the other calculations. How do I extract ONLY that node. I would really appriciate some help thanks!
Expression:
//item/item/concept[@codValue='11820-8']/following-sibling::item/value[@codValue='R-00317']/following::value
<item valType="CONTAINER">
<concept codValue="125005"> MeasureGroup</concept>
<item valType="NUM" relType="CONTAINS">
<concept codValue="11820-8">Bi Diameter</concept>
<value>4.9</value>
</item>
<item valType="NUM">
<concept codValue="11820-8">Bi Diameter</concept>
<value>5.1</value>
</item>
<item valType="NUM">
<concept codValue="11820-8">Bi Diameter</concept>
<item valType="CODE">
<value codValue="R-00317">Mean</value>
</item>
<value>5.0</value>
</item>
</item>
|
|
|
|
|
I hope this works:
/item/item[item/value[@codValue='R-00317']]/value
or
/item/item[item/value='Mean']/value
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
Thanks alot for your help I have been away a while but It I have tried your suggestion below and it extracts the mean value.
/item/item[item/value[@codValue='R-00317']]/value
I still have a small problem though. With your suggestion I also extract the other measurements mean value (see example below) I have tried to “tune” my search using your example, but I don’t get the hang of it, I need to somehow check two different attributes both <value codevalue="R-00317"> and <concept codevalue="”Bi" diamater”=""> instead of just one as before. Is it possible to do that in one expression?
Example code..
<item valtype="CONTAINER">
<concept codvalue="125005"> MeasureGroup
<item valtype="NUM" reltype="CONTAINS">
<concept codvalue="11820-8">Bi Diameter
<value>4.9
<item valtype="NUM">
<concept codvalue="11820-8">Bi Diameter
<value>5.1
<item valtype="NUM">
<concept codvalue="11820-8">Bi Diameter
<item valtype="CODE">
<value codvalue="R-00317">Mean
<value>5.0
<item valtype="CONTAINER">
<concept codvalue="125005"> MeasureGroup
<item valtype="NUM" reltype="CONTAINS">
<concept codvalue="11820-7">ADH length
<value>2.2
<item valtype="NUM">
<concept codvalue="11820-7"> ADH length
<value>2.4
<item valtype="NUM">
<concept codvalue="11820-7"> ADH length
<item valtype="CODE">
<value codvalue="R-00317">Mean
<value>2.3
|
|
|
|
|
oopps.
I forgot to ignore html..Example code..
<item valType="CONTAINER">
<concept codValue="125005"> MeasureGroup</concept>
<item valType="NUM" relType="CONTAINS">
<concept codValue="11820-8">Bi Diameter</concept>
<value>4.9</value>
</item>
<item valType="NUM">
<concept codValue="11820-8">Bi Diameter</concept>
<value>5.1</value>
</item>
<item valType="NUM">
<concept codValue="11820-8">Bi Diameter</concept>
<item valType="CODE">
<value codValue="R-00317">Mean</value>
</item>
<value>5.0</value>
</item>
</item>
<item valType="CONTAINER">
<concept codValue="125005"> MeasureGroup</concept>
<item valType="NUM" relType="CONTAINS">
<concept codValue="11820-7">ADH length</concept>
<value>2.2</value>
</item>
<item valType="NUM">
<concept codValue="11820-7"> ADH length </concept>
<value>2.4</value>
</item>
<item valType="NUM">
<concept codValue="11820-7"> ADH length </concept>
<item valType="CODE">
<value codValue="R-00317">Mean</value>
</item>
<value>2.3</value>
</item>
</item>
|
|
|
|
|
Which attribute did you want to add to the query?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I would like to add the codValue attribut from the concept node.
<concept codValue="11820-8">Bi Diameter</concept>
|
|
|
|
|
/item/item[concept[@codValue='11820-8'] and item/value[@codValue='R-00317']]/value
The concept element, the third level item element(with the value child element) and second level value element (target of the query) are all siblings and children of the second level item element.
George
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi
it was the and operator that I was looking for, didn't knew that you could combine multiple conditions.
Thanks for your help!
|
|
|
|
|
It is users.sql :
use NHibernate
go
CREATE TABLE users (
LogonID nvarchar(20) NOT NULL default '0',
Name nvarchar(40) default NULL,
Password nvarchar(20) default NULL,
EmailAddress nvarchar(40) default NULL,
LastLogon datetime default NULL,
PRIMARY KEY (LogonID)
)
go
It is users.cs :
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NHibernate.Examples.QuickStart
{
public class User
{
private string id;
private string userName;
private string password;
private string emailAddress;
private DateTime lastLogon;
public User()
{
}
public string Id
{
get { return id; }
set { id = value; }
}
public string UserName
{
get { return userName; }
set { userName = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string EmailAddress
{
get { return emailAddress; }
set { emailAddress = value; }
}
public DateTime LastLogon
{
get { return lastLogon; }
set { lastLogon = value; }
}
}
//interface ISession
//{
// void save(users newUser);
// void Save(users newUser);
//}
}
It is User.hbm.xml :
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NHibernate.Examples.QuickStart
{
public class User
{
private string id;
private string userName;
private string password;
private string emailAddress;
private DateTime lastLogon;
public User()
{
}
public string Id
{
get { return id; }
set { id = value; }
}
public string UserName
{
get { return userName; }
set { userName = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string EmailAddress
{
get { return emailAddress; }
set { emailAddress = value; }
}
public DateTime LastLogon
{
get { return lastLogon; }
set { lastLogon = value; }
}
}
//interface ISession
//{
// void save(users newUser);
// void Save(users newUser);
//}
}
It is App.config :
<configuration>
<configsections>
<nhibernate>
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider">
<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect">
<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver">
<add key="hibernate.connection.connection_string" value="Data Source=dev2;Initial Catalog=NHibernate;User ID=sa;Password=buyagift;">
It is Programs.cs :
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace NHibernate
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new NHibernate.Form1());
Application.Run(new NHibernate.Examples.QuickStart.Form1());
}
}
}
This code generates following error:
Unknown entity class: NHibernate.Examples.QuickStart.User
Can anyone help me please?
Thanks
shoaib
|
|
|
|
|
Hello.
I want to build a sample source in Windows 2003 Server Sp1 DDK with XML component.
- sample source : WINDDK\3790.1830\src\print\oemdll\oemui
I installed msxml 4.0 sp1 SDK and
added the following lines to precomp.h in the sample source.
#import "msxml4.dll"
#include <msxml2.h>
using namespace MSXML2;
And then, Opened the build windows to build it.The result is OK.
But, I declared the XML variable like following and builded the source.
IXMLDOMDocument2Ptr pXMLDoc = NULL;
The result was failed like following.
The build of each file was right, but finally the linking was failed.
1>oemui.obj : error LNK2019: unresolved external symbol "void __stdcall _com_iss
ue_error(long)" (?_com_issue_error@@YGXJ@Z) referenced in function "public: __th
iscall _com_ptr_t<class _com_iiid<struct="" msxml2::ixmldomdocument2,&struct="" __s_gu
id="" const="" _guid_2933bf95_7b36_11d2_b20e_00c04f983e60=""> >::_com_ptr_t<class _com_ii
id<struct="" msxml2::ixmldomdocument2,&struct="" __s_guid="" const="" _guid_2933bf95_7b36_11
d2_b20e_00c04f983e60=""> >(int)" (??0?$_com_ptr_t@V?$_com_IIID@UIXMLDOMDocument2@MS
XML2@@$1?_GUID_2933bf95_7b36_11d2_b20e_00c04f983e60@@3U__s_GUID@@B@@@@QAE@H@Z)
1>c:\WINDDK\3790.1830\src\print\oemdll\oemui\oemui.dll : error LNK1120: 1 unresolved externals
BUILD: Done
Plz. Let me know how to build a source with XML variable in Windows DDK.
|
|
|
|
|
|
I was willing to compare current date to the system date. But i didnt make it up. i am pasting the project code below. Please assest me or help me in this matter. and one more thing is that how can i compare the CurrentDate to the ProblemDate if it is grater than the CurrentDate It will give me an error.
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<template xmlns="http://www.xfa.org/schema/xfa-template/2.5/">
<config xmlns="http://www.xfa.org/schema/xci/1.0/">
<agent name="designer">
<destination>pdf
<pdf>
<fontinfo>
<trace>
<present>
<destination>pdf
<pdf>
<fontinfo>
<embed />1
<subsetbelow>100
<interactive>1
<version>1.5
<creator>Adobe LiveCycle Designer 8.0
<producer>Adobe LiveCycle Designer 8.0
<scriptmodel>XFA
<tagged>1
<encryption>
<permissions>
<accessiblecontent>1
<contentcopy>1
<documentassembly>1
<formfieldfilling>1
<modifyannots>1
<print>1
<printhighquality>1
<change>1
<plaintextmetadata>1
<encrypt>
<compression>
<level>6
<compresslogicalstructure>1
<type>
<linearized>1 <batchoutput>
<openaction>
<destination>
<taggedmode>
<viewerpreferences>
<addviewerpreferences>
<duplexoption>
<numberofcopies>
<pagerange>
<silentprint>
<addsilentprint>
<printername>
<common>
<template>
<log>
<to>memory
<mode>overwrite
<uri>C:\DOCUME~1\Junaid\LOCALS~1\Temp\_e3s136fr1fc473jo.log
<threshold>
<uri>
<adjustdata>1
<xsl>
<uri>
<outputxsl>
<uri>
<messaging>
<locale>
<xdp>
<packets>*
<cache>
<macrocache>
<rendercache>
<incrementalmerge>
<runScripts/>
<exclude/>
<currentPage/>
<pagination>
<copies>
<layout>
<to>uri
<uri>C:\Documents and Settings\Junaid\My Documents\Problem Reporting Form.pdf
<acrobat>
<common>
<locale>
<uri>
<adjustdata>1
<xsl>
<uri>
<outputxsl>
<uri>
<template>
<psmap>
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data xfa:datanode="dataGroup">
<localeset xmlns="http://www.xfa.org/schema/xfa-locale-set/2.1/">
<locale desc="English (Canada)" name="en_CA">
<calendarsymbols name="gregorian">
<monthnames>
<month>January
<month>February
<month>March
<month>April
<month>May
<month>June
<month>July
<month>August
<month>September
<month>October
<month>November
<month>December
<monthnames abbr="1">
<month>Jan
<month>Feb
<month>Mar
<month>Apr
<month>May
<month>Jun
<month>Jul
<month>Aug
<month>Sep
<month>Oct
<month>Nov
<month>Dec
<daynames>
<day>Sunday
<day>Monday
<day>Tuesday
<day>Wednesday
<day>Thursday
<day>Friday
<day>Saturday
<daynames abbr="1">
<day>Sun
<day>Mon
<day>Tue
<day>Wed
<day>Thu
<day>Fri
<day>Sat
<meridiemnames>
<meridiem>AM
<meridiem>PM
<eranames>
<era>BC
<era>AD
<datepatterns>
<datepattern name="full">EEEE, MMMM D, YYYY
<datepattern name="long">MMMM D, YYYY
<datepattern name="med">D-MMM-YYYY
<datepattern name="short">DD/MM/YY
<timepatterns>
<timepattern name="full">h:MM:SS A Z
<timepattern name="long">h:MM:SS A Z
<timepattern name="med">h:MM:SS A
<timepattern name="short">h:MM A
<datetimesymbols>GyMdkHmsSEDFwWahKzZ
<numberpatterns>
<numberpattern name="numeric">z,zz9.zzz
<numberpattern name="currency">$z,zz9.99
<numberpattern name="percent">z,zz9%
<numbersymbols>
<numbersymbol name="decimal">.
<numbersymbol name="grouping">,
<numbersymbol name="percent">%
<numbersymbol name="minus">-
<numbersymbol name="zero">0
<currencysymbols>
<currencysymbol name="symbol">$
<currencysymbol name="isoname">CAD
<currencysymbol name="decimal">.
<locale desc="English (United States)" name="en_US">
<calendarsymbols name="gregorian">
<monthnames>
<month>January
<month>February
<month>March
<month>April
<month>May
<month>June
<month>July
<month>August
<month>September
<month>October
<month>November
<month>December
<monthnames abbr="1">
<month>Jan
<month>Feb
<month>Mar
<month>Apr
<month>May
<month>Jun
<month>Jul
<month>Aug
<month>Sep
<month>Oct
<month>Nov
<month>Dec
<daynames>
<day>Sunday
<day>Monday
<day>Tuesday
<day>Wednesday
<day>Thursday
<day>Friday
<day>Saturday
<daynames abbr="1">
<day>Sun
<day>Mon
<day>Tue
<day>Wed
<day>Thu
<day>Fri
<day>Sat
<meridiemnames>
<meridiem>AM
<meridiem>PM
<eranames>
<era>BC
<era>AD
<datepatterns>
<datepattern name="full">EEEE, MMMM D, YYYY
<datepattern name="long">MMMM D, YYYY
<datepattern name="med">MMM D, YYYY
<datepattern name="short">M/D/YY
<timepatterns>
<timepattern name="full">h:MM:SS A Z
<timepattern name="long">h:MM:SS A Z
<timepattern name="med">h:MM:SS A
<timepattern name="short">h:MM A
<datetimesymbols>GyMdkHmsSEDFwWahKzZ
<numberpatterns>
<numberpattern name="numeric">z,zz9.zzz
<numberpattern name="currency">$z,zz9.99|($z,zz9.99)
<numberpattern name="percent">z,zz9%
<numbersymbols>
<numbersymbol name="decimal">.
<numbersymbol name="grouping">,
<numbersymbol name="percent">%
<numbersymbol name="minus">-
<numbersymbol name="zero">0
<currencysymbols>
<currencysymbol name="symbol">$
<currencysymbol name="isoname">USD
<currencysymbol name="decimal">.
<pdfsecurity xmlns="http://ns.adobe.com/xtd/" accessiblecontent="1" change="1" contentcopy="1" documentassembly="1" formfieldfilling="1" metadata="1" modifyannots="1" print="1" printhighquality="1">
<subform name="form1">
<instancemanager name="_">
<subform>
<draw name="StaticHelpDeskRequest">
<draw name="CompanyLogo">
<draw name="StaticCompanyName">
<draw name="StaticAddress">
<draw name="StaticCityState">
<draw name="ZIPPostalCode">
<draw name="Phone">
<draw name="StaticFax">
<draw name="StaticWebSite">
<draw name="Line1">
<draw name="Line1">
<draw name="Line1">
<field name="PrintButton1">
<field name="EmailSubmitButton1">
<draw name="StaticText1">
<field name="ResetButton">
<field name="EmployeeName">
<field name="Department">
<field name="Location">
<field name="Description">
<field name="Region">
<field name="Ticket">
<field name="ProblemDate">
<instancemanager name="_">
<subform>
<field name="PreparedBy">
<field name="Signature">
<field name="CurrentDate">
<instancemanager name="_">
<subform>
<field name="PreparedBy">
<field name="Signature">
<field name="ApprovedDate">
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.0-c316 44.251264, Sun Sep 17 2006 17:15:19">
<rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:description xmlns:xap="http://ns.adobe.com/xap/1.0/" xmlns:xapmm="http://ns.adobe.com/xap/1.0/mm/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="" xap:modifydate="2007-07-11T12:17:54+03:00" xap:createdate="2007-07-04T12:15:43+03:00" xap:metadatadate="2007-07-11T12:17:54+03:00" xap:creatortool="Adobe LiveCycle Designer 8.0" xapmm:documentid="uuid:73ceb2ad-2973-4b62-91b0-1abffd451fb4" xapmm:instanceid="uuid:bbc1e181-4025-48d2-8117-9b22f01289c1" dc:format="application/pdf" pdf:producer="Adobe LiveCycle Designer 8.0">
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<annots>
|
|
|
|
|
Hi
I have to print 14col x 3 rows = 42 labels from my asp.net. I use Xslt transform to display the labels in the aspx page and label width and height also specified in xslt. Also i use style sheet to set paper size a4, and margins,,. When the resultant page is sent to printer from the IE-->Print the Height of each row is shrinked. Any suggestions please.
-- modified at 6:24 Wednesday 11th July, 2007
|
|
|
|
|
CSS has an @-rule for printing: "print". You can use this @-rule to create rules for printing. However, a "Label" in ASP.NET is really a "span" element in the client's browsers. A "span" element is in-line; thus, takes the height of its content. The "height" attribute doesn't have any effect on it. Nevertheless, you can set the said "span" elements' style to "display: block". Consequently, the height attribute will then be effective.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks for your reply George. i have piced the records from db. and using xslt, i transform to html with 3 columns and and 14 rows. I set the paper size to a4 using @print in style sheet. But When printed from a browser(ie), Table size and Table row shrinks a little. Values given in the xslt for each row and table dimensions are not reflected exactly in print. Does the display:block applies to Row of a table in html?
Any suggestions or ideas plz..?
Thank you George
|
|
|
|
|
Unfortunately, CSS1 and <table> don't work well together. Also, it is very difficult to print from HTML exactly the way you want it. I usually generate a PDF (using Crystal Reports) for my clients to print.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Please,I want some help about XSL , for my XML field <description>
it has an image and link like this
<description>
- ]]> aaaaaaaaaaaaaa
My code is --> <xsl:value-of select="description"> but it's show only text no image appear,Iwant to know how to command to show image and link in XLS forms.
thank you.
Kitty
|
|
|
|
|
That's a HTML tag, it's only going to show an image in a web browser.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Is using the html namespace what you're looking for?
<html:img src="http://www.innnews.co.th/crime/47619.jpg" border="0" align="left" width="100" alt="sssss'">
|
|
|
|