472,354 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Extracting Data from Schema Tags

Hi All,

I've been working on mining data from a schema file (all attribute
data so far) and have come to the point where I need to get information
that is contained in tags. For instance, <tag>My Data Here</tag>.
I've tried using the <xsl:value-of select="tag"/> element, but it does
not appear to work in schema files. Is this correct? Is there another
way to get at this data?

-James

Jul 20 '05 #1
4 1520


Porthos wrote:

I've been working on mining data from a schema file (all attribute
data so far) and have come to the point where I need to get information
that is contained in tags. For instance, <tag>My Data Here</tag>.
I've tried using the <xsl:value-of select="tag"/> element, but it does
not appear to work in schema files. Is this correct? Is there another
way to get at this data?


A W3C XML schema is XML and can therefore certainly be processed by a
W3C XSLT stylesheet and there you can use
<xsl:value-of select="elementname" />
to get the string value of an element with name 'elementname'.

It is not clear to me what you are asking about, do you have a W3C XML
schema and want to process that with an XSLT stylesheet? Inside of such
a schema an element is defined as follows e.g.
<xs:element name="elementname" type="xs:string" />
so an XSLT stylesheet could then go and read out
<xsl:value-of
xmlns:xs="http://www.w3.org/2001/XMLSchema"
select="xs:element/@name" />
If the element has complex content then its declaration looks like e.g.
<xs:element name="elementname">
<xs:complexType>
<xs:sequence>
<xs:element name="element2name" />
</xs:sequence>
</xs:complexType>
</xs:element>
then of course a stylesheet trying to process that needs to make sure it
processes subelements like complexType or sequence.
But as I am not sure what you are looking for it is not possible to give
a concrete example.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
"Porthos" <ja*****@vt.edu> writes:
Hi All,

I've been working on mining data from a schema file (all attribute
data so far) and have come to the point where I need to get information
that is contained in tags. For instance, <tag>My Data Here</tag>.
Note "My Data Here" is not contained in any tag (that's essentially the
definition of being data rather than markup) XSLT doesn't have access to
the tags in the original source file. It's _between_ the start tag and
end tag (each of which contain the element type name "tag").
I've tried using the <xsl:value-of select="tag"/> element, but it does
not appear to work in schema files. Is this correct? Is there another
way to get at this data?


A schema file is just a normal XML file as far as XSLT is concerned
there are no special rules at all. However two guesses as to what might
be wrong:

if you are using unprefixed element names such as
<xsl:value-of select="element"/>
then this matches element in no-namespace and you need to match element
in the namespace http://www.w3.org/2001/XMLSchema so you need
<xsl:value-of select="xs:element"/>
together with xmlns:xs="http://www.w3.org/2001/XMLSchema" on your
xsl:stylesheet.

secondly rather few xsd elements have character data content, they
almost all have element content with data being in attributes, for any
such element xsl:value-of will always return the empty string as
it just gives the character data of any descendent element of an
element node.

So you might want for example

<xsl:value-of select="xs:element/@ref"/>

to pull out a ref attribute.

David
Jul 20 '05 #3
Martin,

I have a custom XML schema (.xsd file) and want to process that with
XSLT stylesheet. The schema contains <annotation> tags of the
following general format:

<xsd:schema ...>
<annotation>
<appinfo>
<mytag1>Human Readable Information 1</mytag1>
<mytag2>Human Readable Information 2</mytag2>
</appinfo>
</annotation>
Jul 20 '05 #4
I assumed that since the schema document is an XML document
itself, I could use <xsl:value-of select="mytag1"/>


If the default namespace in your schema file is no-namespace and the
current node at that point in your stylesheet is the xs:appinfo node
then <xsl:value-of select="mytag1"/> will produce
Human Readable Information 1

so if that isn't happening either the element mytag1 isn't in
no-namespace or the current node is not xs:appinfo, but you haven't
shown enough context to guess which.

David
Jul 20 '05 #5

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

Similar topics

5
by: Markus Ernst | last post by:
Hello I have a regex problem, spent about 7 hours on this now, but I don't find the answer in the manual and googling, though I think this must have been discussed before. I try to simply...
1
by: ruthless | last post by:
hello. i've got a question can i in XML Schema define tag that works as lists knows from e.g. C,C++ - recurrent tags? i'm talking about e.g. genealogical tree every level of this tree is...
0
by: Vika Zafrin | last post by:
Hello, group. I am working with some texts, literary and otherwise, marking them up as I go, without a set DTD. I do not plan to have a DTD in place at all, at least not for the encoding part...
5
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail...
4
by: james.eaton | last post by:
I have an XML Schema Document (.xsd) that contains documentation tags (specifically, custom tags subordinate xsd:appinfo). These documentation tags contain strings that may contain ampersands. I...
2
by: gregmcmullinjr | last post by:
I am wondering if there is a way to use a DTD or Schema to instruct an XML parser to ignore tags that are not defined. That is, if my list of acceptable tags is <bodyand <content>, then in the...
2
by: Rami | last post by:
I am using an XSD schema to validate an XML document. I want to validate both XML structure and . When I try to validate the document, the validation only checks for things like proper tags, and...
3
by: Michael | last post by:
If I come up with an XML Schema, do I own the intellectual propertyrights for that schema? Can I legally restrict others from using that schema? I'm in the UK if that makes any difference...
0
by: akshaychand | last post by:
Hi, I am designing a Schema Editor using the Schema Object Model in .NET 2.0. I am currently facing an problem wherein I want to list all the built-in data types as well as the custom types that...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...

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.