473,372 Members | 993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

how to output unresolved xinclude element

I should like to use xslt to produce a document like the following:

<crate xmlns:xi="http://www.w3.org/2001/XInclude">
<rod id="0">
<slot>1</slot>
<xi:include href="./endcapA/disk/1a/10011.xml"/<!--D1A TR
middles-->
<xi:include href="./endcapA/disk/1a/10012.xml"/<!--D1A TR
middles-->
<xi:include href="./endcapA/disk/1a/10001.xml"/<!--D1A TR
outers-->
<xi:include href="./endcapA/disk/1a/10002.xml"/<!--D1A TR
outers-->
<xi:include href="./endcapA/disk/2a/20001.xml"/<!--D2A TR
outers-->
<xi:include href="./endcapA/disk/2a/20002.xml"/<!--D2A TR
outers-->
<xi:include href="./endcapA/disk/3a/30001.xml"/<!--D3A TR
outers-->
<xi:include href="./endcapA/disk/3a/30002.xml"/<!--D3A TR
outers-->
</rod>
</crate>

i.e. it should contain 'manufactured' unresolved xi:include elements.
How can I get my xsl to output such an element?

thanks

shaun
Mar 7 '07 #1
7 1847
i.e. it should contain 'manufactured' unresolved xi:include elements.
How can I get my xsl to output such an element?
The simplest answer: http://www.w3.org/TR/xslt#element-namespace-alias

An alternative is to construct the element explicitly using the
xsl:element directive.

Either will prevent the new element from being prematurely interpreted.

(These tricks are more often used when writing stylesheets that produce
stylesheets, but they're certainly applicable to this problem as well.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 7 '07 #2

The namespace-alias seems neat, but I get a bit of ugliness with it:

I declare my namespaces:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xout="myAlias">

and my alias:

<xsl:namespace-alias stylesheet-prefix="xout" result-prefix="xi"/>

and then use it...

<xout:include href="concat($MurPathRoot,$diskpath,'/',xmlMur) "/>
and sure enough all my elements come out ok:

<xout:include href="./endcapA/disk/1a/10301"/>
but the root document element is:

<configuration xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xout="http://www.w3.org/2001/XInclude">

i.e. its declared both the original xi: and my xout: ... is this
expected?

thanks

shaun

In article <45eee4de$1@kcnews01>,
Joseph Kesselman <ke************@comcast.netwrote:
http://www.w3.org/TR/xslt#element-namespace-alias
Mar 7 '07 #3
shaun roe wrote:
i.e. its declared both the original xi: and my xout: ... is this
expected?
There's a similar directive which lets you suppress namespace
declarations that aren't in use. See the spec and/or Kay's book, or wait
a few hours for me to get around to looking it up.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 7 '07 #4
Joseph Kesselman wrote:
There's a similar directive which lets you suppress namespace
declarations that aren't in use. See the spec and/or Kay's book, or wait
a few hours for me to get around to looking it up.
Since you waited: What you want is the exclude-result-prefixes attribute
of the xsl:stylesheet element. It's described in
http://www.w3.org/TR/xslt#section-Cr...and-Attributes

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 8 '07 #5
In article <Y-******************************@comcast.com>,
Joe Kesselman <ke************@comcast.netwrote:
>There's a similar directive which lets you suppress namespace
declarations that aren't in use. See the spec and/or Kay's book, or wait
a few hours for me to get around to looking it up.
>Since you waited: What you want is the exclude-result-prefixes attribute
of the xsl:stylesheet element. It's described in
http://www.w3.org/TR/xslt#section-Cr...and-Attributes
I think this won't necessarily do quite the right thing in this case.
Despite its name, exclude-result-prefixes specifies a namespace uri to
be excluded, not a prefix. Since in this case he does need the
xinclude namespace, he may well still get a spurious xout prefix
declared somewhere.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Mar 8 '07 #6
Richard Tobin wrote:
I think this won't necessarily do quite the right thing in this case.
Despite its name, exclude-result-prefixes specifies a namespace uri to
be excluded, not a prefix. Since in this case he does need the
xinclude namespace, he may well still get a spurious xout prefix
declared somewhere.
In the implementation I'm familiar with (Xalan), it should do the right
thing, because it's take as a request not to issue any declarations for
prefixes bound to that URI except those which are actually used by an
element or attribute. But while that's a reasonable interpretation It
may not be the only one... Best suggestion I can make is to try it and
see what happens.

If it doesn't work -- well, an unused namespace declaration really is
pretty harmless.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 8 '07 #7
In article <H7******************************@comcast.com>,
Joe Kesselman <ke************@comcast.netwrote:
Richard Tobin wrote:
I think this won't necessarily do quite the right thing in this case.
Despite its name, exclude-result-prefixes specifies a namespace uri to
be excluded, not a prefix. Since in this case he does need the
xinclude namespace, he may well still get a spurious xout prefix
declared somewhere.

In the implementation I'm familiar with (Xalan), it should do the right
thing, because it's take as a request not to issue any declarations for
prefixes bound to that URI except those which are actually used by an
element or attribute. But while that's a reasonable interpretation It
may not be the only one... Best suggestion I can make is to try it and
see what happens.

If it doesn't work -- well, an unused namespace declaration really is
pretty harmless.
I did indeed try this as a first move, and as Richard Tobin has said, it
did not suppress the declaration. (using Saxon) I can live with two
declarations of the namespace, its just not as neat as I'd hoped.

In fact, give that both namespaces are declared anyway in the output, I
found I can reverse the alias/output assignation:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:x="http://www.w3.org/2001/XInclude"
xmlns:xi="myAlias">

..
..
..

<xi:include href="concat($MurPathRoot,$diskpath,'/',xmlMur) "/>
and get, as output:

<configuration xmlns:x="http://www.w3.org/2001/XInclude"
xmlns:xi="http://www.w3.org/2001/XInclude">
..
..
..
..
<xi:include href="./endcapA/disk/2a/20302"/>
which leaves my end users looking at the familiar <xi:include .../>,
which I suspect they will be happier with.

thanks for the help

shaun
Mar 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erdem Guven | last post by:
I try to include some xml documents to another one and validate them. I get 'invalid content starting with element "xi:include".' error message at pointsample.xml line 6 from xml plugin of jedit...
1
by: CB | last post by:
I am using xerces 2.5.0 and xalan 2.6.0, and am following the xinclude instructions on the xerces faq at http://xml.apache.org/xerces2-j/faq-xinclude.html, and I am having no luck. I imagine I...
3
by: rene | last post by:
Hello everybody, i have these 2 xml files ------1.xml------ <?xml version="1.0" encoding="UTF-8"?> <root> <element>1</element> <element>2</element> </root>
1
by: Larry | last post by:
Given the "includer" xml file: <?xml version="1.0"?> <test-includer xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:testns="http://www.w3.org/TR/REC-xml-names"...
9
by: Tjerk Wolterink | last post by:
I have an xml document that conforms to my xschema document. Now i wanted to use xinclude in my xml document. But when i want to validate the xml document to the xschema i get the following...
2
by: tllee | last post by:
I wrote a simple stack program using class template on VC++ 2003 but am unable to resolve the following link errors: LINK : error LNK2020: unresolved token (0A000046) Stack.__dtor LINK : error...
11
by: john fra | last post by:
Hi, I want to include a part of many XML files into an unique XML file with XInclude. Example! File1.xml, File2.xml, File3.xml... seems to that : <?xml version="1.0" encoding="UTF-8"?>
4
by: Tim Arnold | last post by:
I'm using ElementTree to access some xml configuration files, and using the module's xinclude capability. I've got lines like this in the parent xml file (which lives in the same directory as the...
2
by: McSwell | last post by:
I have an XML file that looks something like this: ------------------------ <?xml ...?> <!DOCTYPE ...> <src:fragment id="foo" ...> <Ph:Itemsome stuff </Ph:Item> <Ph:Itemsome more stuff...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.