|
Hi!
Hmmm... the last code example you provided works fine for me.
But if you're sure you're doing everything else right, try changing your output type to HTML:
<xsl:output method="html"/>
Add this just below your xsl:stylesheet tag if you don't already have an output type, change it to "html" if you do.
It could work but I can't replicate your problem so I have no way to be sure.
Hope This Helps!
MrWolfy
|
|
|
|
|
You can always use a CDATA section if the & escape is causing problems.
|
|
|
|
|
Just use entity references: < > and &
It might be messy to go through an entire XML doc to convert values containing these special characters so, in the past, I used to just load the XML into a XML DOM object and then get it again - the DOM object does the conversion for you!
(ignore the HTML tags in my sig - I turned off HTML so that the entity references show up)
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Hi,
While calling the validate method I am getting the following error while validating the XML:
<b>"Validate failed because the document does not contain exactly one root node."</b>
The XMLDOM object i am creating is Msxml2.DOMDocument.4.0
I am having only one root but don't know why this error
Here is my XSD:
<xsd:schema id="XSDSchemaTest" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="DriverDetails">
<xsd:sequence>
<xsd:element name="VendorURLPath" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="DriverCureServerURLPath" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="MD5" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ProductName" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="DriverVersionInfo" type="xsd:string" minOccurs="1" maxOccurs="1" />
<xsd:element name="ContentWriterInfo" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Drivers">
<xsd:complexType>
<xsd:choice>
<xsd:element name="Driver" type="DriverDetails" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
And here is the XML :
<?xml version="1.0" encoding="UTF-8" ?>
<Drivers xsd:SchemaLocation="F:\kuldeep\ProjectWork\XMLExtractorMFC\XMLSchema.xsd">
<Driver>
<VendorURLPath123>http://www.yahoo.com</VendorURLPath123>
<DriverCureServerURLPath>http://www.yahoo.com</DriverCureServerURLPath>
<MD5>12345678</MD5>
<ProductName123>abcd</ProductName123>
<DriverVersionInfo>Version No 1.1</DriverVersionInfo>
<ContentWriterInfo>Made By Microsoft</ContentWriterInfo>
</Driver>
</Drivers>
Anyone Please let me know what can be problem with this.
Kuldeep
|
|
|
|
|
The schema location attribute in the root node is wrong, since you don't have a namespace in your instance. Here is an instance that works:
<Drivers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="F:\kuldeep\ProjectWork\XMLExtractorMFC\XMLSchema.xsd">
<Driver>
<VendorURLPath/>
<DriverCureServerURLPath/>
<MD5/>
<ProductName/>
<DriverVersionInfo/>
<ContentWriterInfo/>
</Driver>
</Drivers>
Also make sure that your schema actually exists at the specified location and is valid.
Here's some more information:
http://msdn.microsoft.com/en-us/library/ms256139(VS.85).aspx
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
i have this xml here, and now i would like to use xsl to transform into sql statement like this:
update OrderDetails set Quantity = 2 where OrderID = 10248 and ProductID = 11
Here is the XML document:
<Order ID="10248">
<OrderItem ProductID="11">
<QuantityIncrease>2</QuantityIncrease>
</OrderItem>
</Order>
Here is a bit i did:
<?xml version="1.0" encoding="UTF-8">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:input href ="WriteXMLToDBTest_Order.xml"/>
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="Order"/>
</xsl:template>
<xsl:tempalte match="Order">
<xsl:text>update</xsl:text>
<xsl:value-of select="Order Details"/>
</xsl:tempalte>
</xsl:stylesheet>
as i am still new in this field, can someone guide me through?
Many thanks
|
|
|
|
|
AndieDu wrote: as i am still new in this field, can someone guide me through?
Make sure the Database product you are using does not have it's own facility to import XML before you go creating SQL statements, most of the major products support that.
led mike
|
|
|
|
|
sorry mate, i am not quite get what do you mean, in here actually i need a example
cheers
|
|
|
|
|
|
Thanks very much, i appreciated your effort.
cheers
Andie
|
|
|
|
|
I've been writing VST[^] plugins for the past year and a half or so.
Every VST plugin has a set of parameter values each having the range of [0, 1]. To be more specific, these parameter values are what the host in which the plugin is running understands. It's up to each plugin to transform these normalized parameter values into values it can use. For example, a plugin may have an amplitude parameter and want to transform it to a range of [0, 10] using an exponential curve. Another example is a plugin that needs to map parameter values to a set of choices, e.g. Sine, Cosine, Square, Sawtooth, etc...
With VST v2.4, Steinberg implemented vstxml for representing parameter data in XML. However, I find that the schema is not nearly rich enough to represent the wide range of VST parameter data. So I thought I'd take a stab at it myself. The end goal being one in which a plugin could read an XML file and configure its parameters accordingly.
The trouble is that I know very little about modeling data with XML. So I thought I'd throw out a couple of attempts and get some feedback, hopefully pointing me in the right direction.
Here's an example I came up with of a VST parameter represented in XML:
<parameter id="0" name="Waveform" type="selection">
<entry name="Sine"/>
<entry name="Cosine"/>
<entry name="Triangle"/>
</parameter>
The above declares a parameter with the id of 0, the name Waveform, and the type selection. The selection type indicates that the parameter represents a selection of choices. The entry element represents a choice.
A plugin parsing this would know to transform the normalized [0, 1] parameter value given to it by the host into an integer in the range of [0, 2], mapping each integer value to the appropriate element, e.g. a value of 0 would indicate the Sine waveform has been chosen.
Here's another example:
<parameter id="1" name="Level" curve="exponential" min="0" max="10" \>
This describes a parameter with an id of 1, the name Level, the curve exponential, and having the range of [0, 10].
A plugin parsing this would know to transform the normalized [0, 1] parameter value given to it by the host to a floating point number in the range of [0, 10] using an exponential curve (value * value * 10).
Does this seem to be a resonable approach?
|
|
|
|
|
is there any google webservice available to get the bulk geocoding? i need to get list of long/lat from the response
|
|
|
|
|
mkanna wrote: is there any google webservice available to get the bulk geocoding?
Welcome to CodeProject.com
Looks like you took a wrong turn in a router somewhere because I think you are looking for code.Google.com[^]
led mike
|
|
|
|
|
I'm trying to create a list containing subtypes of an abstract type in xml and validate it using an xml schema
I tried to use this as a schema but when i try to validate i get an error telling me that I cannot use transaction because it's marked abstract. Basically I'm trying to end up with a list that contains transaction nodes some of which are of type transaction1 and some are transaction2.
<pre><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="rootelement" type="docroot" />
<xs:complextype name="docroot">
<xs:sequence>
<xs:element name="transactions" type="transactions" />
</xs:sequence>
</xs:complextype>
<xs:complextype name="transactions">
<xs:sequence>
<xs:choice minoccurs="0" maxoccurs="unbounded">
<xs:element name="transaction" minoccurs="0" maxoccurs="unbounded" type="transaction" />
</xs:choice>
</xs:sequence>
</xs:complextype>
<xs:complextype name="transaction" abstract="true">
<xs:sequence>
<xs:element name="content" minoccurs="1" maxoccurs="1" />
<xs:element name="extracontent" minoccurs="0" maxoccurs="1" />
<xs:element name="noextracontent" minoccurs="0" maxoccurs="1" />
</xs:sequence>
<xs:attribute name="type" />
</xs:complextype>
<xs:complextype name="transaction1">
<xs:complexcontent>
<xs:restriction base="transaction">
<xs:sequence>
<xs:element name="content" minoccurs="1" maxoccurs="1" />
<xs:element name="extracontent" minoccurs="1" maxoccurs="1" />
<xs:element name="noextracontent" minoccurs="0" maxoccurs="0" />
</xs:sequence>
<xs:attribute name="type" fixed="1" />
</xs:restriction>
</xs:complexcontent>
</xs:complextype>
<xs:complextype name="transaction2">
<xs:complexcontent>
<xs:restriction base="transaction">
<xs:sequence>
<xs:element name="content" minoccurs="1" maxoccurs="1" />
<xs:element name="extracontent" minoccurs="0" maxoccurs="0" />
<xs:element name="noextracontent" minoccurs="1" maxoccurs="1" />
</xs:sequence>
<xs:attribute name="type" fixed="2" />
</xs:restriction>
</xs:complexcontent>
</xs:complextype>
</xs:schema></pre>
The code above is only for testing, I'm trying to get my head round how restriction etc works in schema.
Does anyone know how to do this?
Cheers,
Russell
|
|
|
|
|
From what I can see, you have a couple of problems:
* Everything is in lower-case, so complextype is not the same as the (correct) complexType. (This also applies to complexcontent/complexContent, etc)
* The complexType 'transactions' contains a sequence that contains a choice. You cannot limit a choice in this way. Here is the right way:
<xs:complexType name="transactions">
<xs:sequence >
<xs:element name="transaction" type="transaction" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
So I removed the choice to get it to work.
For reference, here is what the final schema looks like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="rootelement" type="docroot" />
<xs:complexType name="docroot">
<xs:sequence>
<xs:element name="transactions" type="transactions" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="transactions">
<xs:sequence >
<xs:element name="transaction" type="transaction" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="transaction" abstract="true">
<xs:sequence>
<xs:element name="content" minOccurs="1" maxOccurs="1" />
<xs:element name="extracontent" minOccurs="0" maxOccurs="1" />
<xs:element name="noextracontent" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="type" />
</xs:complexType>
<xs:complexType name="transaction1">
<xs:complexContent>
<xs:restriction base="transaction">
<xs:sequence>
<xs:element name="content" minOccurs="1" maxOccurs="1" />
<xs:element name="extracontent" minOccurs="1" maxOccurs="1" />
<xs:element name="noextracontent" minOccurs="0" maxOccurs="0" />
</xs:sequence>
<xs:attribute name="type" fixed="1" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="transaction2">
<xs:complexContent>
<xs:restriction base="transaction">
<xs:sequence>
<xs:element name="content" minOccurs="1" maxOccurs="1" />
<xs:element name="extracontent" minOccurs="0" maxOccurs="0" />
<xs:element name="noextracontent" minOccurs="1" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="type" fixed="2" />
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453
|
|
|
|
|
Hi,
I have some variables
public string clientCase;
public string vmlCase;
public string caseDate;
public string caseType;
public string category;
public string testName = string.Empty;
public string comment;
public string orderdBy;
know i want to make a XML file from it using c#.net in this format.
<TestOrderd>
<CaseID> clientCase </caseID>
<Tests>
<Test>testname</test>
<Test>testname</test>
<Test>testname</test>
</Tests>
<Comments>comment</Comments>
<OrderOn>caseDate</OrderOn>
</TestOrder>
|
|
|
|
|
Use an xmldocument object and the createelement and appendchild methods to create your new elements and add them to the document tree.
you can output the contents of the xmldocument element using the xmldocument.xml method.
Russell
|
|
|
|
|
Check out the XmlSerializer class.
|
|
|
|
|
|
krishna, welcome to codeproject
Take the time to read this handy forum guidelines article[^]. Pay attention to item #6.
led mike
|
|
|
|
|
Hi All,
I have an unformatted xml string text which looks as below
<Value Name="Param1" Length="0" Type="System.Double">3</VALUE> <Value Name="Param2" Length="0" Type="System.Double">2</VALUE>
I want to read values from the above xml text. I have tried it to make it
XmlDocument object but it is giving error as illegal characters exist. Please give me advice how to read values from this text. If posible give me a small code snippet.
Thanks,
Aleem Mohammad.
NIIT technologies
abdul.aleem@niit-tech.com
|
|
|
|
|
This is not XML, therefore your question does not belong in this forum. Do you know why ? Do you know how XML is defined ?
1 - it has one root element
2 - it is case sensitive.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi, i need to convert a raw xml file into another xml file using xslt. I have no idea how to achieve the desire output. Can anyone provide an example? Thanks.
Input xml:
<root>
<header>
<row>
<entry>header</entry>
<entry>name1</entry>
<entry>result1</entry>
</row>
<row>
<entry>header</entry>
<entry>name2</entry>
<entry>result2</entry>
<entry>result22</entry>
</row>
<row>
<entry>reading</entry>
<entry>name3</entry>
<entry>result3</entry>
</row>
<row>
<entry>reading</entry>
<entry>name4</entry>
<entry>result4</entry>
<entry>result5</entry>
</row>
</header>
</root>
The final xml will be like this:
<root>
<header>
<row>
<name>name1</name>
<result>result1</result>
</row>
<row>
<name>name2</name>
<result>result2</result>
<result2>result2</result2>
</row>
</header>
<reading>
<row>
<name>name3</name>
<result>result3</result>
</row>
<row>
<name>name4</name>
<result>result4</result>
<value>result5</value>
</row>
</reading>
</root>
<div class="ForumMod">modified on Monday, August 25, 2008 11:25 AM</div>
|
|
|
|
|
Member 4703966 wrote: I have no idea how to achieve the desire output.
Anyone who is a beginner would be in that same situation. Rather than ask someone to do it for you, you should be learning the XML/XSLT technology, that's what a developer does.
Member 4703966 wrote: Can anyone provide an example?
There are many examples on the internet. Try the Top XML site and www.w3schools.com, both have great tutorials with sample/example code.
led mike
|
|
|
|
|
Since you voted my post down I guess that means you don't believe that as a developer you should learn the technology you need to work with.
Ok, good luck.
led mike
|
|
|
|