xml

Xsl relative path for xsl:import or xsl:include

I am trying to use VBSctipt to do an xslt transform on an xml object. The xsl file I'm translating includes the <xsl:import href="script.xsl"/> directive. If I use the absolute href (http://localhost/mysite/script.xsl) it imports the style sheet fine; however, if I use the relative path (script.xsl) it reports "resource not found". I ne...

What's the best way to format 24 hour time in XSLT 1.0?

I've had a hard time finding good ways of taking a time format and easily determining if it's valid then producing a resulting element that has some formatting using XSLT 1.0. Given the following xml: <root> <srcTime>2300</srcTime> </root> It would be great to produce the resulting xml: <root> <dstTime>23:00</dstTime> </root...

Using SimpleXML to create an XML object from scratch

Is it possible to use PHP's SimpleXML functions to create an XML object from scratch? Looking through the function list, there's ways to import an existing XML string into an object that you can then manipulate, but if I just want to generate an XML object programmatically from scratch, what's the best way to do that? I figured out tha...

JAXB Binding Customization

Hi people, While trying to generate classes from a xsd, i got this error: java.lang.IllegalArgumentException: Illegal class inheritance loop. Outer class OrderPropertyList may not subclass from inner class: OrderPropertyList My xsd define a element to group a unbounded element like this: <element minOccurs="0" name="orderProperty...

Add a namespace to elements using XSLT

I have an XML document with un-namespaced elements, and I want to use XSLT to add namespaces to them. Most elements will be in namespace A; a few will be in namespace B. How do I do this? ...

xpath query searching text

Give the following XML structure <html> <body> <div> <span>Test: Text2</span> </div> <div> <span>Test: Text3</span> </div> <div> <span>Test: Text5</span> </div> </body> </html> What is the best xpath query to locate any span with text that starts with Test? ...

In SQL Server can I insert multiple nodes into XML from a table?

I want to generate some XML in a stored procedure based on data in a table. The following insert allows me to add many nodes but they have to be hard-coded or use variables (sql:variable): SET @MyXml.modify(' insert <myNode> {sql:variable("@MyVariable")} </myNode> into (/root[1]) ') So I coul...

I have a 100+MB XML file (sans-DTD/Schema). XSLT won't have it. Strategies for transforming/parsing?

This XML file contained archived news stories for all of last year. I was asked to sort these stories by story categor[y|ies] into new XML files. big_story_export.xml turns into lifestyles.xml food.xml nascar.xml ...and so on. I got the job done using a one-off python script, however, I originally attempted this using XSLT. This r...

Abstracting storage data structures within XPath

I have a collection of data stored in XDocuments and DataTables, and I'd like to address both as a single unified data space with XPath queries. So, for example, "/Root/Tables/Orders/FirstName" would fetch the value of the Firstname column in every row of the DataTable named "Orders". Is there a way to do this without copying all of th...

What's the accepted way of storing quoted data in XML?

What's the accepted way of storing quoted data in XML? For example, for a node, which is correct? (a) <name>Jesse "The Body" Ventura</name> (b) <name>Jesse \"The Body\" Ventura</name> (c) <name>Jesse &quot;The Body&quot; Ventura</name> (d) none of the above (please specify) If (a), what do you do for attributes? If (c), is it really...

change mime type of output in php

I've got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML. Is there any way to change the returned mime type of the php output on the fly from text/html to text/xml or application/xml? ...

XML Attributes vs Elements

When should you use XML attributes and when should you use XML elements? e.g. <customData> <records> <record name="foo" description="bar" /> </records> </customData> or <customData> <records> <record> <name>foo</name> <description>bar</description> </record> </records> </customData> ...

.NET XmlDocument LoadXML and Entities

When loading XML into an XmlDocument, i.e. XmlDocument document = new XmlDocument(); document.LoadXml(xmlData); is there any way to stop the process from replacing entities? I've got a strange problem where I've got a TM symbol (stored as the entity #8482) in the xml being converted into the TM character. As far as I'm concerned this...

How do I create an Xml file using templating similar to ASP.NET

I need to generate an XML file in C#. I want to write the code that generates this in a file that is mostly Xml with code inside of it as I can in an ASP.NET MVC page. So I want a code file that looks like: <lots of angle brackets...> <% foreach(data in myData) { %> < <%= data.somefield %> <% } %> More angle bracke...

How to add an attribute to an XML node in Java 1.4

I tried: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f); Node mapNode = getMapNode(doc); System.out.print("\r\n elementName "+ mapNode.getNodeName());//This works fine. Element e = (Element) mapNode; //This is where the error occurs //it seem...

XML Parsing Error: SYSTEM or PUBLIC, the URI is missing

I am parsing an RSS feed from the following URL: http://rss.sciam.com/ScientificAmerican-Global?format=xml // $xml_text is filled with the contents read from the URL $xml_parser = xml_parser_create(); $res = xml_parse($xml_parser, $xml_text); if (!$res) { $error = xml_error_string(xml_get_error_code($xml_parser)). " at line ...

How can I create XML from Perl?

Hello I need to create XML in Perl. From what I read, XML::LibXML is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is XML::Writer still maintained? Does anyone like/use it? In addition to feature-completeness, I am interested an easy-to-use syntax, so please desc...

Validating and reparing xml

Is there a way to get more useful information on validation error? XmlSchemaException provides the line number and position of the error which makes little sense to me. Xml document after all is not about its transient textual representation. I'd like to get an enumerated error (or an error code) specifying what when wrong, node name (or...

I need a LINQ expression to find an XElement where the element name and attributes match an input node.

I need to replace the contents of a node in an XElement hierarchy when the element name and all the attribute names and values match an input element. (If there is no match, the new element can be added.) For example, if my data looks like this: <root> <thing1 a1="a" a2="b">one</thing1> <thing2 a1="a" a2="a">two</thing2> <thing2 ...

How to throw a XmlSchemaException on XML Schema validation errors?

Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function gets a ValidationEventArgs parameter which in turn has an Exception property of the type XmlSchemaException. Whew! My current code looks like this: ValidationEventHandler onValidationError = delegate(object sender, Vali...