| toine |
| Newbie |
|
| Montreal, Canada |
|
|
| None Specified |
|
| Tuesday, July 14, 2009 |
| Thursday, October 8, 2009 1:28:25 PM |
5 [0.03% of all post / 0.00 posts per day] |
|
vlad wrote:From XML point of view xmlns is NOT an attribute - it is a namespace declaration and it only impacts the way how elements are processed but kind of does not exist as such.
Therefore you will have to probably explicitly create xmlns in your output by xsl:attribute
Thanks Vlad. I tried, but I get an "Illegal attribute name" error. I'll post a solution when I find one...
|
We are using XSLT to transform an XML document into HTML.
this is the beginning of the stylesheet:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xbrldi="http://xbrl.org/2006/xbrldi" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="#all" xmlns:mds="http://www.hospitalis.ca/PTM/mds">
<xsl:variable name="DocID" select="/mds:DocumentMDS/@Id"/> <xsl:include href="target_Transform.xslt"/> <xsl:include href="HTML_Transform_Common.xslt"/> <xsl:output method="html" indent="yes" encoding="UTF-8" use-character-maps="spaces" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /> <xsl:character-map name="spaces"> <xsl:output-character character=" " string="&nbsp;"/> </xsl:character-map> <xsl:import-schema schema-location="../Schemas/PTM_Document_MDS.xsd"/>
<xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
the resulting HTML looks like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="fr" lang="fr"> <head>....
The xml:lang and lang attributes are correctly output in the HTML. The xmlns declaration disappears. I have played around with the stylesheet declaration, but to no avail. Does anyone know why this is happening? Thanks in advance...
|
vlad wrote:If I understand you properly you have an id for the first and last section and need to find all sections between them?
You can try to use position() function for this. For example, provided that the first section has id = 5 and last id = 3
some-parent-element/section[@id = 5]/position() gives you a position of the first section
some-parent-element/section[@id = 3]/position() of a second one
and then you use them to filter all sections within (by using variables or directly using statements above)
some-parent-element/section[position()>= $from and position() <= $till]
Thanks for the response Vlad, and sorry for the delay in responding. This solution looks like it could work. I did find another solution that worked for us as well. In essence, we did something like this:
([@SectionId]=$From]/following-sibling::element()) intersect ([@SectionId]=$To]/preceding-sibling::element())
So we generated a node set from the start element and all its following siblings and another node set from the end element and all its preceding siblings. Then we used the intersect function to give us the correct node set. (I simplified the XPath above for clarity. You need to add the start and end nodes to either side of the intersect to have them included.)
|
Thanks for the reply Paul.
I forgot to mention that the id's for the document are not necessarily sequential (or even necessarily integers for that matter. The id attribute is of type xs:id) So my document can look something like this:
<section id="1"> <...> <...> </section> <section id="2"> <...> <...> </section> <section id="5"> <...> <...> </section>
<section id="3"> <...> <...> </section>
This is due to the fact that users can modify the document. We really need to be able to find the nodes that are physically between the start node and the end node. (We have a system where we generate web pages based on these xml files. Sections of other documents can be viewed from within the current document in a kind of folding panel. The client would like to define these "include links" by defining a start and endpoint so that subsequent modifications to the document (ie: a new section being added) are included without having to modify the original link. Does that make sense?)
I don't know if this is even possible. The closest we have come is by passing a list of id's to the id function like so: id(1;2;5;3). This is close to what we want, but not exactly what we need.
thanks again.
|
I have an XML document that has the following basic structure:
<section id="1"> <...> <...> </section> <section id="2"> <...> <...> </section> <section id="3"> <...> <...> </section> ...
Is there a way using XPath or XQuery to find all the nodes that are between a start id and an end id? For example, In my XSLT I want to use the following construct: document("docpath")//id("1-3") to load an entire section of the other document that is between the start and end nodes. Thanks in advance
|
|