xslt

XSLT: How to reuse a template within another template

If I have a template as follows, which is used to create a button: <xsl:template match="button" name="button"> <a class="button" href="{@href}"> <xsl:value-of select="@name"/> </a> </xsl:template> I want to be able to use that button in another template, like this: <xsl:template match="createForm"> ... <button name="Creat...

How to show XSL-converted XML as a part of an HTML page?

Can I embed an XML file in HTML without using iFrames? I want to show XSL-transformed XML(which, is HTML as a result of transformation) as a part of my HTML document. Hope this makes it clearer. If my description of problem is unclear, please tell me and I will try to explain it more. ...

Localize dates on a browser?

Let's say I have a date that I can represent in a culture-invariant format (ISO 8601). I'll pick July 6, 2009, 3:54 pm UTC time in Paris, a.k.a. 5:54 pm local time in Paris observing daylight savings. 2009-07-06T15:54:12.000+02:00 OK... is there any hidden gem of markup that will tell the browser to convert that string into a loca...

Using a parameter as the select of an xsl:for-each

I've got the following ... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" (etc.) > <xsl:param name="Query"/> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <r:results> <xsl:for-each select="$Query"> (etc.) ...

Prevent DTD download when using XSLT i.e. XML Transformer

I have to process XML files that have a DTD with a XSLT in Java. The DTD is really needed because it contains the definitions of entities I use. (aside: yes, using entities for stuff that could use unicode is a bad idea ;-) When I run the transformation it downloads the DTD from the external source every time. I want it to use a XML cat...

archive-like format using XML

Hi all, I'm generating some code using XSLT but the generated sources should be localized in a set of distinct files. Is there a tool/format (based on XML ?) that could be used to store the files in a jar/ar/tar-like format . I'm thinking of something like this: <?xml version="1.0"?> <archive> <file path="test/Test01.java" content-type=...

xsl: how to tell if a variable has been declared

I have a variable in my xsl that may or may not be declared. How can I tell if it has been declared. The issue is I have 2 style sheets. A parent (where the global variable is declared) and a child (where the global variable is referenced). I usually call the parent stylesheet which then calls the child stylesheet. So everything is ...

XSLT pass array of Integers

Hos do I pass array of Integers as a params to XSLT?. ...

Cocoon lite / XML and XSLT publishing framework

What publishing frameworks (publishing only, NOT full-blown CMS) based on XML, XSLT sitemaps and pipelines exist, are stable, active, and simpler / lighter than Cocoon? I have glanced at: mod_xslt (http://www.mod-xslt2.com/) which seemed to be exactly that, but looks all but dead, and required a complex setup, and apparently supported...

XSLT: Use Named template to copy XSD to XSD

I have the XSD content in this file. Using this xsl, I can copy the contents of the desired element: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:template match="node()|@*" name="copy"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="xs:comple...

Stripping spaces between XML nodes with Python

Is there a easy way to accomplish the same thing in Python as xsl accomplishes with: <xsl:strip-space elements="*"/> So for instance in the following for event, elem in ElementTree.iterparse("/tmp/example.xml"): if elem.tag == "example": print ElementTree.tostring(elem) when the example nodes are printed out all the sp...

How do I Filter an XML via an XSLT with xml params

Here is my input XML: <Books> <Book> <BookId>1</BookId> <Des>Dumm1</Des> <Comments/> <OrderDateTime>04/06/2009 12:37</OrderDateTime> </Book> <Book> <BookId>2</BookId> <Des>Dummy2</Des> <Comments/> <OrderDateTime>04/07/2009 12:37</OrderDateTime> </Book> <Book> <BookId>3</BookId> <Des>Dumm...

XSLT: Copy Where current type value equals the name of an element

Using this file as source, I have a situation where I need to retrieve an element from either the local source file or a related one noted in the imports. The type value uses a colon to separate the two values - substring-before(@type, ':') tells me which file to reference; substring-after(@type, ':') is the name of the element in the f...

XSLT: Turn <element></element> into <element />

What do I need to do to this: <xsl:template match="xs:simpleType"> <xsl:copy> <xsl:copy-of select="node()[not(self::xs:annotation or self::xs:restriction)]|@*"/> </xsl:copy> </xsl:template> Currently, this turns out: <xs:simpleType xmlns:core="urn:org:pesc:core:CoreMain:v1.4.0" name="SINIDType"> </xs:simpleType> I...

I18n for XSLT (or what is the gettext() and xgettext of C++ for XSLT)?

Complete C++ i18n gettext() “hello world” example shows a standard way to handle messages in a C++ program using gettext(). The message catalogs are stored in Portable Object files based upon a Portable Object Template file created directly from the C++ source code using xgettext, msginit and msgfmt. What is the corresponding method for ...

Generate low-order non-printable characters from XLST

I'm trying to use XSLT text output to generate a file (in a file format that I'm not in control of), and while it is mostly text, it includes low-order non-printable characters as flags, including characters that are not valid within an XLST file (according to the XSLT specification). I'd like for something like the below to work, but i...

XSLT - Replace apostrophe with escaped text in output

I'm writing an XSLT template that need to output a valid xml file for an xml Sitemap. <url> <loc> <xsl:value-of select="umbraco.library:NiceUrl($node/@id)"/> </loc> <lastmod> <xsl:value-of select="concat($node/@updateDate,'+00:00')"/> </lastmod> </url> Unfortunately, Url that is output contains an apostrophe - /what's-new.aspx I...

XSLT: Parsing HTML embedded in XML?

On my web site I have XMLs with my page contents (automatically generated from my DB) - which are displayed using XSLT. The problem is this: I'd like to have some formatting within some of the XML tags. For instance, if I have an XML containing an article in a format like this: <article> <header>Cool article</header> <author>Me!</a...

XSLT: Selective Node Handling

I have the following xsd snippet: <xs:complexType name="HighSchoolType"> <xs:sequence> <xs:element name="OrganizationName" type="core:OrganizationNameType"/> <xs:group ref="core:OrganizationIDGroup" minOccurs="0"/> </xs:sequence> </xs:complexType> I want to handle xs:element tags differently than xs:group tags, while complet...

XSLT Bitwise Logic

I have an existing data set that utilizes an integer to store multiple values; the legacy front end did a simple bitwise check (e.g. in C#: iValues & 16 == 16) to see if a particular value was set. Is it possible to do bitwise operations in XSL, and more explicitly, to do bit level comparisons via masking? The built-in "and" will always ...